Google Calendar sync with php in 2 ways

11,902

Solution 1

There are no application hooks in Google Calendar (gCal) that allow you to trigger an action when an event is deleted. Instead you must either poll gCal at intervals (this could be a cron job every few minutes/hours) and update your calendar accordingly, or any time you perform an action from your calendar have a 1 in X possibly of a full re-sync.

This implies that you are using the gCal as the definitive source, and mirroring those changes back to your local application.

Solution 2

well, after following these answers and building a hole 2 way sync process, i realized there's a push notifications for calendar since 2013. you will still need a full sync process because the push notification only notifies about a change but no data about the change. hope it will save you some time.

Push Notifications

Solution 3

Would it not be an option for your system to generate an iCal output at a special, user-specific URL, and then have the user subscribe to that calendar in Google Calendars (or their iCal-reading calendar of choice)?

That way, your system would always hold the authorative calendar, and Google Calendar would reflect any changes you make automatically.

Alternately, if you are wanting changes in the Google Calendar to be reflected in your application, then you may be able to subscribe to iCals for the User's Calendar, and then poll them at a regular interval to reflect any changes the User has made at that end.

I would lean towards the first option (your iCal subscribed through Google Calendar), as it is a simpler and easier solution.

Share:
11,902
user563860
Author by

user563860

Updated on June 09, 2022

Comments

  • user563860
    user563860 almost 2 years

    I am creating a php website that uses the Google Calendar API. It's working fine with Create, Update and Delete: any event from the PHP website goes into my Google Calendar events after login.

    Events created on my site are created in Google Calendar.

    What I want now that is: when I create an event from my test page it goes into Google Calendar after login, then if I update or delete that event from Google Calendar then it should automatically update or delete the php website event.

    Basically: 1-way sync is working fine but now I want 2-way synchronization.

    If anybody has any ideas then kindly share with me, it will be much appreciated.

  • JoshBerke
    JoshBerke almost 13 years
    I agree with Andy here, that there is no way in the API to do this
  • elbowlobstercowstand
    elbowlobstercowstand over 8 years
    If you're shaking your head in disbelief [like me] that the push from the API notifies that a calendar changed but not what changed, this post—unfortunately—confirms the bad news.