我正在使用谷歌日历推送通知。一切都很好,我注册我的频道没有任何问题。日历的更改将按预期的方式发出通知。
我要停止推送通知。我正在调用谷歌停止推送通知API。"https://www.googleapis.com/calendar/v3/channels/stop“,但我得到了错误代码:404 and message: "Channel not found for project"。
请求:
googleCalendar.channels.stop({
auth: oauth2Client,
resource: {
id: 'cfabcfaa-a6eb-4432-8068-6417ee2ce8a6', //channelID
resourceId: '3kGwQdmzSMCZ41MAFdwEzt0ugNQ' //resourceID
}
}, function(err, results) {
if(err){
return;
}
console.log(results) })响应:
{ [Error: Channel 'cfabcfaa-a6eb-4432-8068-6417ee2ce8a6' not found for project '87165627894']
code: 404,
errors:
[ { domain: 'global',
reason: 'notFound',
message: 'Channel \'cfabcfaa-a6eb-4432-8068-6417ee2ce8a6\' not found for project \'87165627894\'' } ] }有人能帮我解释一下为什么我会犯这个错误吗?谢谢。
发布于 2016-01-06 06:06:07
我无法确定您是否在使用库,但似乎您调用的是calendarList表方法,而不是通道停止方法(用于停止推送通知)。
基于Calendar API文档中的推送通知页面,所需的字段实际上是channelID和resourceID (正如您所指定的;还需要用户的第一个令牌)
https://www.googleapis.com/calendar/v3/channels/stop
POST https://www.googleapis.com/calendar/v3/channels/stop
Authorization: Bearer {auth_token_for_current_user}
Content-Type: application/json
{
"id": "4ba78bf0-6a47-11e2-bcfd-0800200c9a66",
"resourceId": "ret08u3rv24htgh289g"
}https://stackoverflow.com/questions/34618420
复制相似问题