【问题标题】:emitting a nodejs event when an event on google calendar is added or updated添加或更新谷歌日历上的事件时发出 nodejs 事件
【发布时间】:2016-01-28 04:59:23
【问题描述】:
添加或修改 Google 日历事件时是否可以发出 nodejs 事件?在我的 nodejs 服务器上,我可以获取/列出日历上的所有事件。但我想根据 nodejs 事件检索事件,而不是在定期间隔后手动检查它。欣赏任何想法!
【问题讨论】:
标签:
node.js
google-calendar-api
google-api-nodejs-client
【解决方案1】:
其实是可以的,如这里所说:https://developers.google.com/google-apps/calendar/v3/push
您可以注册一个回调 URL,以便您的应用在您的事件发生更改或被修改时接收信息。使用 Node.JS API,它类似于:
calendar.events.watch({
auth:jwtClient,
resource: {
id: "yourChannelId",
type: 'web_hook',
address: "https://www.yoursite.com/notifications"
},
calendarId: "yourcalendarId"
}, function(error, response) {
if (error) {
console.log(error);
return;
}
console.log(response);
});
【解决方案2】:
不可能。类似的事情需要谷歌知道关于你的应用程序(发送事件或推送数据)。 Google 的 API 仅供访问。它不能“告诉”您的应用程序任何事情。您的应用必须是“询问”Google 它想要的东西是否存在或已经发生的应用。