const jwtClient = new google.auth.JWT(
privatekey.client_email,
null,
privatekey.private_key,
['https://www.googleapis.com/auth/calendar']);
//authenticate request
jwtClient.authorize(function (err, tokens) {
if (err) {
console.log(err);
return;
} else {
console.log("Successfully connected!");
}
});
const activatePushNotification = function(calendarID) {
calendar.events.watch({
auth: jwtClient,
calendarId: calendarID,
singleEvents: true,
orderBy: 'startTime',
resource: {
"id": uuid.v1(),
"type": 'web_hook',
"address": 'https://example.com/notification'
}
}, (err, test) => {
console.log(err, test, '<------------------->');
})
}
我正在使用上面的example
代码来向我的域激活推送通知,每当我change
或add new event
到该日历时,它就应该将通知推送到我的域,但是目前我正面临着推送通知问题多次击中了我的域,大约400 above times
左右。请帮助我解决这个问题。