wanasit / google-calendar

Google Calendar API connection in Node.js
MIT License
230 stars 54 forks source link

register domain for push notification? #11

Closed darkrai0101 closed 8 years ago

darkrai0101 commented 10 years ago

how can I do this?

thanks

wanasit commented 10 years ago

Sorry for the delayed response

The push notification (events.watch) is very new feature that they just updated the document. I have included the new function to the library but haven't tested it yet.

First, follow this document https://developers.google.com/google-apps/calendar/v3/push

After you register you verify and register your domain, you should be able to register for push notification of any calendar by this code:

var calendar_id      = 'CALENDAR_ID'
var watch_request = { 
          "id"     : "01234567-89ab-cdef-0123456789ab", 
          "type"   : "web_hook",
          "address": "https://wanasit.github.io/notifications", 
     }

gcal.events.watch(calendar_id, watch_request, function(err, result) {
     console.log(err)  
     console.log(result) 
})