Take the 2-minute tour ×

I'm writing a php script responsible for retrieving calendar events from a project management system and synchronizing them with a user's Google Calendar. I have the code able to create events and push them to Google Calendar, but the problem I'm having is that the event can be created numerous times with the same parameters. My code to create the event is as follows (it's from the Google Calendar API documentation):

$event = new Event();
$start = new EventDateTime();
$end = new EventDateTime();
$attendees = array($attendee1);
$event->attendees = $attendees;

$createdEvent = $calendarService->events->insert('myCalendarId', $event);

If I run this code, it creates the event as required. Now, perhaps I'm not doing this correctly, but this is the code I'll be using to synchronize the calendars. I'll have this code run while the user is browsing the site, but the problem is that any events it's already created it will just re-create.

For clarification: A user has an meeting at 11am on the 25th. The code runs, and inserts that meeting into Google. The next iteration of the code will insert that same meeting again.

How can I find out if a created event in Google is the same as one currently in my system? I can enumerate the events from Google, which do expose IDs and eTags, but they're not the same with identical events that have yet to be added coming from my system...


share|improve this question

1 Answer 1

Every event has a unique id. While creating a fresh event, the Google calender returns the created event. You have to save the id to update this event in future. Try this one..

$calendarService->events->update($calendarId, $eventId, Event $postBody, $optParams = array())
share|improve this answer

Your Answer


