| he Google Calendar API Client Library for Delphi provides functionality common to Google Calendar API, for example Event creation, error handling, authentication, JSON parsing, etc.The library includes a powerful OAuth 2.0 support with a consistent interface. You can use the Google Calendar API for Delphi to find and view public calendar events as well as to manage private calendars and events on those calendars.This article describes how to create calendar events programmatically and add them to your users' calendars. |
Create EventsThe usage of the Google Calendar API for Delphi is simple and is similar to
You can't view the links! Click here to register and
You can't view the links! Click here to register. The structure and members of classes from Google Calendar API for Delphi helps you to easily migrate an existing .NET or Java code to Delphi.For creating a Google Calendar event, you need to select the desired calendar ID and call to the Insert method of the Events collection:
[td]var
insertReq: TEventsInsertRequest;
event: TEvent;
...
event := TEvent.Create();
event.Start := TEventDateTime.Create();
event.Start.DateTime := Now() + 1;
event.End_ := TEventDateTime.Create();
event.End_.DateTime := Now() + 2;
event.Summary := 'Sample event';
insertReq := GetService().Events.Insert(calendarId, event);
try
event := insertReq.Execute();
finally
insertReq.Free();
end;
...
//use event
...[/td]
OAuth authorizationTo work with Google Calendar API you need first to create the Calendar Service instance and set up the OAuth credentials. Your application must send an OAuth 2.0 token with any request that accesses private user data. With
You can't view the links! Click here to register you can set up the desired Project Name, Client ID and Client Secret that are necessary to generate OAuth 2.0 credentials for your application. The Calendar Service initialization code may look like the following:
[td]// [Delphi]
function TCalendarServiceTests.GetService: TCalendarService;
var
credential: TGoogleOAuthCredential;
initializer: TServiceInitializer;
begin
if (FService = nil) then
begin
credential := TGoogleOAuthCredential.Create();
initializer := TGoogleApisServiceInitializer.Create(credential, 'CleverComponents Calendar test');
FService := TCalendarService.Create(initializer);
credential.ClientID := '421475025220-6khpgoldbdsi60fegvjdqk2bk4v19ss2.apps.googleusercontent.com';
credential.ClientSecret := '_4HJyAVUmH_iVrPB8pOJXjR1';
credential.Scope := 'https://www.googleapis.com/auth/calendar';
end;
Result := FService;
end;[/td]
Supported compiler versionsGoogle Calendar API for Delphi can be used in RAD Studio XE3 and later. If you modify the sources and remove all references to the RAD Studio namespaces in the 'uses' sections, you can use the library in RAD Studio 2009, 2010, XE and XE2 as well.Download source codeThe library is distributed under the terms of the
You can't view the links! Click here to register,
You can't view the links! Click here to registerThe current version of Google API Client Library for Delphi needs for the non-free library
You can't view the links! Click here to register. This is a drawback, and we suggest the task of changing the program so that it does the same job without the non-free library. Anyone who thinks of doing substantial further work on the program, first may free it from dependence on the non-free library. The class structure allows you to easily replace the Clever Internet Suite Http and Oauth components with any other third-party free and non-free software.