Google javascript API库-日历监视通知
我正在尝试使用JS客户端库订阅日历事件通知,如下所示:Google javascript API库-日历监视通知,javascript,calendar,google-api,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",
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);
});
});
但我一直收到400条返回消息,其中包含一条毫无帮助的消息“Entity.Resource
”
在响应的数据对象中,我得到域:全局,消息:Entity.Resource,reason:Required“
我已经通过oauth2认证,并且我已经通过我的Google帐户授予访问权限,我可以成功检索日历列表,我正在从日历中检索事件,但是订阅手表的这种方法不起作用?请帮助我,我在Google上找不到任何与此相关的信息。您需要在e向日历API发出的请求,以区分您的请求,如下所示
{
"id": string,
"token": string,
"type": string,
"address": string,
"params": {
"ttl": string
}
}
如需进一步参考,请参阅
您可以使用以下语法:
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));
}
});
希望它能起作用。你知道你的请求的内容类型吗?我在!=application/json时看到过这个错误。这对我没有帮助。令牌是可选的。
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));
}
});