Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save hiddentribe/c27c7b54fe68e89ac43d6ecb5f43a676 to your computer and use it in GitHub Desktop.

Select an option

Save hiddentribe/c27c7b54fe68e89ac43d6ecb5f43a676 to your computer and use it in GitHub Desktop.
Google Calendar Webohooks

Google Calendar Webohooks

Unsplash

function doPost(e) {
var date = new Date();
date.setHours(0, 0, 0);
var events = Calendar.Events.list('primary', { orderBy: 'updated', updatedMin: date.toISOString() });
var lastEvent = events.items[events.items.length - 1];
var res = [lastEvent.id, lastEvent.status, lastEvent.summary];
SpreadsheetApp.openById('ce4944c16c20e94c8777').appendRow([new Date()].concat(res));
return ContentService.createTextOutput('200').setMimeType(ContentService.MimeType.TEXT);
}
function watch() {
var t = Calendar.Events.watch({ address: 'https://script.google.com/macros/s/8ab02d4deb4243336380/exec', type: 'web_hook', id: '6245dfb802d7b93fa8fa' }, 'primary');
// Save resourceId
Logger.log(JSON.stringify(t));
}
function getChannals() {
Calendar.Channels.stop({ id: '6245dfb802d7b93fa8fa', resourceId: '????' });
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment