I am trying to sync google calendar with my website.I am using google client php api. Till now i am able to get all the events from google calendar.Is there a way to get only the updated events from google calendar. Below is the code to get the events from google calendar
$client = new Google_Client();
$client->setApplicationName( $app_name );
$client->setDeveloperKey( $app_key );
$cal = new Google_Service_Calendar( $client );
$calendarId = $app_id;
$params = array(
'singleEvents' => true,
'orderBy' => 'startTime',
);
$events = $cal->events->listEvents($calendarId, $params);
foreach ( $events->getItems() as $event ) {
echo $event->getSummary();
}
I guess you can only use orderBy
parameter. It has a value "updated" that orders the events by last modification time (ascending). Here is the documentation.
I'm looking into the same feature, but apparently their public Google Calendar API does not allow that. Seems like the only way is to get the master recurring event and compare it against all event instances (field by field). I bet they have an internal API that provides that info for internal calendar synchronization.
Sorry, no PHP code, I use C# and REST API.
In API v3 you can use param updatedMin.
$datetime = \DateTime::createFromFormat("Y-m-d H:i:s", "2019-07-14 05:40:00");
$events = $service->events->listEvents('primary', [
"updatedMin" => $datetime->format(\DateTime::RFC3339)
]);