Google javascript API库 - 日历观看通知

ANd*_*mes 4 javascript calendar google-api

我正在尝试使用JS客户端库订阅日历事件通知,如下所示:

gapi.client.load('calendar', 'v3', function () {
            var request = gapi.client.calendar.events.watch({
                'calendarId': cl.gCalendarID,
                'id': unid,
                'type': "web_hook",
                'address': {my url here}
            });
            request.execute(function (resp) {
                console.log(resp);
            });
        });
Run Code Online (Sandbox Code Playgroud)

但是我只是继续得到400回复,并且没有任何帮助Entity.Resource"

在我得到的响应的数据对象中 Domain:global, Message: Entity.Resource, reason: Required"

我已经通过oauth2进行了身份验证,并且我已经授予了访问我的Google帐户的权限,并且我可以成功检索日历列表,并且我正在从他们的日历中检索事件,但这种订阅手表的方法不起作用?请帮助我在Google上找不到任何关于此的内容.

San*_*kar 6

Instead of this:


 var request = gapi.client.calendar.events.watch({
                'calendarId': cl.gCalendarID,
                'id': unid,
                'type': "web_hook",
                'address': {my url here}
            });
Run Code Online (Sandbox Code Playgroud)

您使用以下语法:

calendar.events.watch({
            auth: auth,
                resource: {
                    id: "12345",
                    type: 'web_hook',
                    address: {mu url here}
                 },
                calendarId: 'primary' 

            }, function(err, response) {
                if (err) {
                    logger.MessageQueueLog.log("info","index.js:- watchnotification(),Error in Watch Notification: " + err);

                } else {          
                   logger.MessageQueueLog.log("info","index.js:- watchnotification(), Notification : " + JSON.stringify(response));           

                }
            });
Run Code Online (Sandbox Code Playgroud)

希望它会奏效.