module.exports.hook = (req, res) => {
resourceId = req.headers['x-goog-resource-id'];
console.log('received signal from Google');
console.log('listen on channel ID: ', req.headers['x-goog-channel-id']);
console.log('and resource ID is:', req.headers['x-goog-resource-id']);
listEvents(auth);
};
module.exports.createChannel = (id, callback) => {
const calendar = google.calendar({ version: 'v3', auth });
calendar.events.watch({ // post method
auth,
calendarId: 'primary',
resource: {
id,
type: 'web_hook',
address: `https://super.eu.ngrok.io/notifications?id=${id}`,
},
}, (error, result) => {
if (error) throw error;
callback(result);
});
};
Это то, что я пытался. Я не мог найти какую-либо конкретную информацию. Пожалуйста, помогите. Заранее спасибо. Я совершенно новичок в Google API.