Trigger script on Google calendar event

和自甴很熟 提交于 2020-01-03 11:03:03

问题


I want to trigger some script when new calendar event is created in Google Calendar (say calling some rest API that enters event information to my database). I do not want any kind of UI that triggers the script.
Is it possible to achieve this using Google gadget since I do not want any UI? I would really appreciate the help as I am new to Google API.

Thanks a lot
Shubhra


回答1:


Calendar API has something like notifications. See this link: Push Notifications. From documentation:

The Google Calendar API provides push notifications that let you watch for changes to resources. You can use this feature to improve the performance of your application. It allows you to eliminate the extra network and compute costs involved with polling resources to determine if they have changed. Whenever a watched resource changes, the Google Calendar API notifies your application.




回答2:


Google Calendar API (relevant docs) provides a watch endpoint that allows you to specify a webhook upon certain events.

To set up the webhook, you can call the Calendar API endpoint a POST request to https://www.googleapis.com/calendar/v3/calendars/calendarId/events/watch with the body

{
  "id": string
  "type": string,
  "address": string
}

The "address" field tells Calendar what endpoint to call when there is a new Calendar event. You'll need to create and host this endpoint yourself.

Another option is to use a service like Zapier, which has fantastic integrations for Google Calendar and makes setting up a listener (i.e. a trigger) and corresponding action very simple.



来源:https://stackoverflow.com/questions/21301918/trigger-script-on-google-calendar-event

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!