Google Calendar API on add event callback for sync - google-api

I am using google-api-php-clientfor fetching and inserting Google Calendar events. Now I want to synchronize events on my system with events on Google Calendar.
I am wondering, if I add Event in Google Calendar, can it be automatically added in my system (maybe with some callback url) so I don't need to use CRON jobs to recheck events in Google Calendar in some time interval?
Thank you!

Google provides both iCal and XML output for viewing from external applications. This URL can be found by clicking on the drop down from your calendar name while logged in, selecting settings, and the calendar name. The private address row gives you both iCal and XML URLs.
Here are instructions for Outlook and iCal.

Related

How to be aware of the creation of a new event in a google calendar? [duplicate]

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
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.

How to set available and unavailable times for a google resource for booking?

I'm looking for a way to set time availability and unavailability of the google calendar resources.
At the moment, I could create google calendar resource with google admin api. But the problem is, I don't know how to set available time for them that could use in booking process — creating an event in google calendar, and assign a resource to that event.
There's no any attribute to address this requirement here in documentation.
Alternative solution:
Apparently, there's no a straight forward procedure for bounding the time range of a resource calendar. So I decided to bound a resource calendar by creating fake events for those time ranges that the calendar should be unavailable. In this way, the users cannot book (i.e. create any events) on those specific time ranges!
OR
You can read every changes on a calendar (polling or push notification if applicable), then compare the created events with your system's events, and if there are any events that have conflicts with the system's events (booking), decline those google calendar events consequently.

Is there any way to get notification of changes to google calendar

i have an application that updates events in google calendar. however user can also open google calendar via browser and update events from there. is there any way that my app can get a notification if someone else makes changes to the calendar?

Google Calendar event Created/Updated/Deleted Webhook?

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
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.

Subscribing to external ical programmatically

Through the Google Calendar UI a user can add an external iCAL calendar to their CalendarList.
When that Calendar is retrieved through CalendarList, the Calendar URL is not included. Additionally, it doesn't appear that it's possible to add an external iCal Calendar to a user's CalendarList.
Is this the case? Is there a way of programmatically subscribing a Google Calendar user to an external iCal feed?
Internally the Calendar UI uses the following URL to add an external calendar:
https://calendar.google.com/calendar/addcalendarfromurl
This URL takes the the following parameters by either POST or GET:
curl: calendar url (url encoded).
cimp: UI sets this to true, not sure what it does.
cpub: true|false - make calendar public
secid: security id from the client (session Id perhaps). Not specifying this brings a 403 error.
If the user isn't logged into the Calendar they will be redirected to the Google Login screen. If I had a way of generating a secid (perhaps OAUTH?), I could add a link to allow the user to add the calendar automatically.
Unfortunately there doesn't seem to be any updates on Google Calendar API having an import .ics feature. A ticket has been logged since 2007 and still doesn't have any resolution as of this moment.
The only option I can find is to manually import the .ics file in the user's Google Calendar web UI. The Import events to Google Calendar support page discusses the issue.
Step 2: Import events into Google Calendar
After you've exported your events, you can import them into Google Calendar.
Open Google Calendar on a computer. Note: You can only import from a computer, not a phone or tablet.
In the top right, click Settings settings gear button > Settings.
Open the Calendars tab.
Click Import calendars between the "My calendars" and "Other Calendars" sections.
Click Choose File and select the file you exported. The file should end in "ics" or "csv"
Choose which calendar to add the imported events to. By default, events will be imported into your primary calendar.
Click Import.
If you're using a ZIP file, find it on your computer and open it. You'll see ICS files for each of your calendars. Take the individual files out of the ZIP file, and import each ICS file individually.
Note: Repeating events might not show up that way if you import them from a CSV file, but they'll be on your calendar as a series of one-time events.

Resources