I am developing a SPA webapp through which I add events to my users google calendar They have given permission for. However this is my first time using Google calendar API, and was unclear about how to retrieve my users existing events , or if they add new events or delete them. IS there an option to set a webhook within google calendar thus when the user makes any changes to the calendar I can receive the change. My current approach was to make multiple get requests but that seems very inefficient. How can I keep my app calendar in sync with all user created events.
You can set up a push notification to be alerted any time anything changes on one of your calendars. I looked into it before a little, if memory serves it doesn't alert you to a lot of particularly useful information (I don't believe it tells you exactly what changed and how). Check out the docs here: https://developers.google.com/google-apps/calendar/v3/push
What I ended up doing was setting up a cronjob and getting all of my calendars' events using the synctoken, which returns only the events that have changed since the last time I polled the API for events. https://developers.google.com/google-apps/calendar/v3/sync
watch
API method for the calendar. I mean push notification doesn't support a calendar. But it has watch API for events. In this way, you can be aware of any changes to your created events not creating a new event on the calendar. According to the documentation: "Currently, the Google Calendar API supports notifications for changes to the Acl, CalendarList, Events, and Settings resources." –
Altigraph If you are using the SyncToken in your request for data, all you get back is the events that have changed. There is an eventID in the Google records that you can use to connect the change to your event data.
This google calendar API says that it sends webhook notifications when there are changes to Events: https://developers.google.com/calendar/api/v3/reference/events/watch
Notifications will be sent to an address you provide:
address string The address where notifications are delivered for this channel.
Unfortunately, I'm not seeing any documentation of what the webhook notifications look like that are sent to your endpoint.
© 2022 - 2024 — McMap. All rights reserved.