123ArticleOnline Logo
Welcome to 123ArticleOnline.com!
ALL >> Computer-Programming >> View Article

Google Calendar Component (delphi Internet Components)

Profile Picture
By Author: Sergey Shirokov
Total Articles: 2
Comment this article
Facebook ShareTwitter ShareGoogle+ ShareTwitter Share

clever internet suite Abstract In this article, I will show you how to write your own Google Calendar in Delphi using Internet components from Clever Internet Suite library. The reason why I decided to write this article is that the standard Google API does not provide a library for working with Calendar via Delphi. This is the first part of series describing a simple Delphi component that authorizes using the Google API service and implements several commands for working with calendar events. In future articles of the series, I will write about other Google Calendar commands and also about oAuth authorization in Google API services. About CalDAV protocol Many websites provide online services for computations, storing of data, working with emails, task scheduling and many other useful things. Some services are implemented by using Cloud Technologies. Often it's necessary to organize communication between an online service and an application that runs on a local ...
... PC via special API that the online service provides for developers. In most cases such API's use HTTP-based Internet protocol: HTTP itself, WebDAV, CalDAV, etc. The commands and data are transferred in XML, SOAP or SOAP-WSDL format. We will need to use two Internet components for working with the service API: the first one supports the HTTP protocol and the latter composes HTTP requests in XML format. Let's go ahead and write some simple code in Delphi that connects to the Google Calendar API and creates a new event. The Google Calendar API uses a special protocol - CalDAV. This protocol represents an extension of the WebDAV protocol. You can learn more about both WebDAV and CalDav protocols by reading the documentation at RFC 4918 and RFC 4791. Create a Google Calendar event The following two steps are needed to create a new event in Google Calendar in Delphi: connect to Google API and authorize the request; send a CalDAV command in XML format to the web service. Both steps require a WebDAV client and code that composes HTTP requests in the appropriate format. All this functionality can be found in the Internet Components - Clever Internet Suite library. Alternatively, you can use any other Internet library, e.g. Indy, that is the core part of RAD Studio installation. But in fact, the Clever Internet Suite provides a set of flexible Internet components that communicate via both HTTP/HTTPS and WebDAV protocols, allow data compression and also support various authentication methods: Basic, Digest, NTLM, Negotiate and Kerberos. You can connect from your application to most popular online services: Google Calendar, Youtube, Picasa, Yahoo, Windows Live services and many more. To transfer data over the Internet let's use TclWebDAV component. This component includes a fully-functional WebDAV (and HTTP as well) client and implements all WebDAV and HTTP commands. We will create a new component and include TclWebDAV within it. To be simple, let's add properties for the event to this component. In a future version of this component, we will move it to a separate class in the same way that Google .NET Client Library does. TclGoogleCalendar = class(TComponent)
private
FWebDav: TclWebDav;
FRequest: TclHttpRequest;
.......
published
property Email: string read GetEmail write SetEmail;
property Password: string read GetPassword write SetPassword; property EventTitle: string read FEventTitle write FEventTitle;
property EventContent: string read FEventContent write FEventContent;
property EventWhere: string read FEventWhere write FEventWhere;
property EventStartTime: string read FEventStartTime write FEventStartTime;
property EventEndTime: string read FEventEndTime write FEventEndTime;
end; The TclHttpRequest component combines an HTTP request in the appropriate format for creating a new Google Calendar event: createRequest := '<entry....' + '<title type=''text''>' + EventTitle + '</title>'...; FRequest.Clear();
FRequest.AddTextData(createRequest);
FRequest.Header.Authorization := 'GoogleLogin ' + AuthID;
FRequest.Header.ContentType := 'application/atom+xml'; A list of Google Calendar commands can be found in the Google Calendar APIs Log in to Google Calendar For working with Google online services, you must authorize your requests first. Different authorization interfaces that are used in Google API are described in Authorizing requests and identifying your application Please see below a sample of using the ClientLogin Google API interface: FRequest.Clear();
FRequest.AddFormField('accountType', 'HOSTED_OR_GOOGLE');
FRequest.AddFormField('Email', Email);
FRequest.AddFormField('Passwd', Password);
FRequest.AddFormField('service', 'cl');
FRequest.AddFormField('source', 'Delphi_Google_Calendar_API');

FWebDav.Post('https://www.google.com/accounts/ClientLogin', FWebDav.Response);

ind := Pos('Auth=', FWebDav.Response.Text);
if (ind > 0) then
begin
FAuthID := System.Copy(WebDav.Response.Text, ind, 10000);
end; The FAuthID value should be added to all subsequent HTTP request headers in order to authorize it. Download source code The complete source code for working with Google Calendar can be downloaded here: Download Google Calendar Delphi component with sample Download Clever Internet Suite library To install the component, first, download and install Clever Internet Suite library. Next, unpack the gcalendar.zip archive. This archive includes a project file GCalLib.dpk. You need to open it in your Delphi IDE, modify the "uses" section (see the comments within the dpk file), build and install the package. The provided component implements only few Google API functions for working with Calendar. You can extend it on your own or you can use it as a starting point for developing your own functionality. The component can be run in Delphi 5-7, 2005-2010, XE and XE2 since the Clever Internet Suite supports all these versions of Delphi and C++ Builder as well. Please feel free to contact me at Customer Portal

Total Views: 568Word Count: 1299See All articles From Author

Add Comment

Computer Programming Articles

1. Wordpress Website Developer
Author: seema

2. Shopify Web Designer India
Author: seema

3. Business Analyst Certification Course Training In Bhopal
Author: Rohan Rajput

4. The Evolution Of On-demand Mobile App Market
Author: Qurilo Solutions

5. Essential Features Every Fmcg Sales App Needs In 2025
Author: Amit Kumar

6. Explore The Best Business Analytics Courses In Bhopal | Start Your Data-driven Career Today
Author: Rohan Rajput

7. The Unseen Guardian: Unraveling The Mystery Of Your Digital Firewall
Author: adhvaidh

8. Laravel Framework: The Ultimate Guide For Modern Web Development
Author: Umang Patel

9. Custom Mobile App Development
Author: SEO Niotechone Software

10. Best Business Analytics Courses In Bhopal | Top Institutes & Career Opportunities 2025
Author: Rohan Rajput

11. Discover Business Analytics Courses In Bhopal At Raj Institute Of Coding & Robotics
Author: Rohan Rajput

12. Top Ai Agents Companies
Author: Felipe Nunez

13. How A Hospital Management System Can Improve Healthcare In Zambia
Author: Agness Ruth

14. "elevate Your Programming Skills With Lcc Computer Education's Expert Training"
Author: Khushi Gill

15. Business Analytics Courses In Bhopal – A Smart Career Move With Raj Institute Of Coding & Robotics
Author: Rohan Rajput

Login To Account
Login Email:
Password:
Forgot Password?
New User?
Sign Up Newsletter
Email Address: