Google 日历 API 在尝试获取我的所有日历事件时返回 404

Google Calendar API returns a 404 when trying to get all my calendar events

本文关键字:日历 事件 返回 获取 API Google 我的      更新时间:2023-09-26

我正在尝试将所有事件记录到控制台。应该相当简单,但由于某种原因它找不到我的日历(id 绝对正确,并且我的 API 密钥在我的实际代码中不是空白的。

<html>
<head>
    <title>Google Calendar Example</title>
    <script src="client.js"></script>
    <script>
        var apiKey = '';
        function load()
        {
            gapi.client.setApiKey(apiKey);
            gapi.client.load('calendar', 'v3', function()
                {
                    var request = gapi.client.calendar.events.list({
                        'calendarId': 'timtamboy63@gmail.com'
                    });
                    request.execute(function(resp)
                    {
                        console.log(resp);
                    });
                });
        }
    </script>
</head>
<body>

</body>
</html>

回应:

Object {code: 404, message: "Not Found", data: Array[1], error: Object}

知道出了什么问题吗?

您的日历 ID 不正确。它应该看起来像 gma9l2if4e75ta6cr7ubndts@group.calendar.google.com