Google javascript API库 - 日历观看通知 [英] Google javascript API library - Calendar watch notifications
问题描述
我想使用JS用户端程式库订阅日历活动通知,例如:
I am trying to subscribe to calendar event notifications with the JS client library like this:
gapi.client.load('calendar', 'v3', function () {
var request = gapi.client.calendar.events.watch({
'calendarId': cl.gCalendarID,
'id': unid,
'type': "web_hook",
'address': {mu url here}
});
request.execute(function (resp) {
console.log(resp);
});
});
但我只是得到400返回一个无益的消息实体。资源
But I just keep getting 400 returned with an unhelpful message of "Entity.Resource
"
在响应的数据对象中,我获得 Domain:global,Message:Entity.Resource,reason :必需
In the data object of the response I get Domain:global, Message: Entity.Resource, reason: Required"
我已通过oauth2验证,并且已授予我的Google帐户访问权限,我可以成功检索日历列表我正在从他们的日历检索事件,但这种方法订阅手表将无法工作?请帮助我在谷歌上找不到任何关于这个。
I am authenticated already with oauth2 and I have granted access with my Google account and I can successfully retrieve the list of calendars and I am retrieving events from them calendars but this method to subscribe to the watch will not work? Please help I can't find anything on Google about this.
推荐答案
Instead of this:
var request = gapi.client.calendar.events.watch({
'calendarId': cl.gCalendarID,
'id': unid,
'type': "web_hook",
'address': {mu url here}
});
您使用此语法:
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));
}
});
希望它能工作。
这篇关于Google javascript API库 - 日历观看通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!