Google Calendar | Sync Events

The process to get all events from a calendar is very easy. Just follow the next steps:

 

  1. Call the method LoadEvents and pass the CalendarId as parameter.
  2. If the method returns True, then you can access the Calendars.Events property and iterate over the list to get access to all Events of the calendar.

 


oGoogleCalendar := TsgcHTTPGoogleCloud_Calendar_Client.Create(nil);
// ... configure OAuth2 options
oGoogleCalendar.GoogleCloudOptions.OAuth2.ClientId := 'google ClientId';
oGoogleCalendar.GoogleCloudOptions.OAuth2.ClientSecret := 'google ClientSecret';
// ... request calendars first
oGoogleCalendar.LoadCalendars;
// ... request events from first calendar
oCalendar := TsgcGoogleCalendarItem(oGoogleCalendar.Calendars.Calendar[0]);
if oGoogleCalendar.LoadEvents(oCalendar.ID) then
begin
  // ... get events data
  for i := 0 to oCalendar.Events.Count - 1 do
    vEventTitle := oCalendar.Events[i].Summary;
end
else
  raise Exception.Create('Error Event Sync');