gpt4 book ai didi

node.js - 谷歌API日历 watch 不起作用,但 channel 已创建

转载 作者:太空宇宙 更新时间:2023-11-03 21:57:54 25 4
gpt4 key购买 nike

我尝试监听我的日历更改事件 ( google-apps/calendar/v3/reference/events/watch )。

我从 Google 控制台端、域中完成了所有操作 - 好的,一切都已验证,我成功创建了 channel 。我还成功获得了带有正确标题的 sync 消息(见下文)。来自文档:

Sync message

After creating a new notification channel to watch a resource, the Google Calendar API sends a sync message to indicate that notifications are starting. The X-Goog-Resource-State HTTP header value for these messages is sync. Because of network timing issues, it is possible to receive the sync message even before you receive the watch method response.

这意味着通知正在开始

但是,当我更改 snaggs@comp.com 帐户中的某些内容时 -没有任何反应,没有请求发送到回调:'https://dev-api.mycompany/google-watch/'

这是我的工作代码:

var google = require('googleapis');
var googleAuth = require('google-auth-library');
var _ = require('underscore-node');


var uuid = require('node-uuid');

// ......

var channel_id = uuid.v1();


_auth.credentials = {
access_token: _token.access_token,
token_type: _token.token_type,
refresh_token: _token.refresh_token,
expiry_date: _token.expiry_date
};

var data = {
auth: _auth,
calendarId: _token.provider_email,
singleEvents: true,
orderBy: 'startTime',
resource: {
id: channel_id,
token: 'email='+_token.provider_email,
address: 'https://dev-api.mycompany/google-watch/',
type: 'web_hook',
params: {
ttl: '36000'
}
}

};

calendar.events.watch(data, function (err, response) {
if (err) {
console.error('The API returned an error: ' + err);
return;
}
});

当我开始上面提到的代码片段时,我得到响应:

{
"kind": "api#channel",
"id": "277fa000-d4b6-12e5-ab58-e7afaf85ea65",
"resourceId": "C7vFL07CYfqaHy3vDss4qugWDfk",
"resourceUri": "https://www.googleapis.com/calendar/v3/calendars/snaggs@comp.com/events?orderBy=START_TIME&singleEvents=true&alt=json",
"token": "email=snaggs@comp.com",
"expiration": "1455667451000"
}

'https://dev-api.mycompany/google-watch/' URL 中,我收到有关文档的 sync 消息,例如(请参阅 google-apps/calendar/v3/push ):

{
"host": "dev-api.mycompany",
"accept": "*/*",
"accept-encoding": "gzip,deflate",
"user-agent": "APIs-Google; (+https://developers.google.com/webmasters/APIs-Google.html)",
"x-goog-channel-expiration": "Tue, 16 Feb 2016 22:44:51 GMT",
"x-goog-channel-id": "277fa000-d4b6-12e5-ab58-e7afaf85ea65",
"x-goog-channel-token": "email=snaggs@comp.com",
"x-goog-message-number": "1",
"x-goog-resource-id": "C7vFL07CYfqaHy3vDss4qugWDfk",
"x-goog-resource-state": "sync",
"x-goog-resource-uri": "https://www.googleapis.com/calendar/v3/calendars/snaggs@comp.com/events?orderBy=START_TIME&singleEvents=true&alt=json",
"x-forwarded-for": "56.102.7.132",
"x-forwarded-port": "443",
"x-forwarded-proto": "https",
"content-length": "0",
"connection": "keep-alive"
}

但不存在消息

我错过了什么吗?

请帮忙,

最佳答案

我们使用推送通知已有几年,并注意到在过去 24 小时内,我们没有收到数千个日历中的任何通知。

像您一样,我们可以创建/停止 channel ,但通常不会收到任何更改通知。

大约一个小时前,我们再次收到它们。请重试您的 channel ,因为这可能是 Google Push 方面的问题,但已解决。

关于node.js - 谷歌API日历 watch 不起作用,但 channel 已创建,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35434828/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com