The Google calendar API is at its root very powerful, but you have not worked with XML/HTTP, cookies or authentication in the past learning the raw API can be daunting. Fortunately Google provides a free .NET library, so you can interact with a user’s Google Calendar using intuitive .NET classes and methods.
To get started, download the .NET client API from here:
Add references to the Google libraries in your project, and use or import these in your code
The library provides a “Service” class to handle connecting to and authenticating with Google:
Service service = new Service("cl", "companyName-appName-1");
You then execute a query on the service. The query will return a list of AtomEntry objects, which are handy wrappers for standard RSS Atom entries. For example, this returns a list of all items in the user’s calendar:
FeedQuery query = new FeedQuery();
query.Uri = new
AtomFeed calFeed = service.Query(query);
foreach (AtomEntry entry in calFeed.Entries)
There are similar methods for adding, updating, or deleting calendar items. For example:
AtomPerson author = new AtomPerson(AtomPersonType.Author);
author.Email = "email@example.com";
entry.Title.Text = "Lunch at Bully's";
entry.Content.Content = "Eat lunch with Fred";
When eventTimes = new When();
eventTimes.StartTime = DateTime.Parse("7/13/2009 12:00:00 PM");
eventTimes.EndTime = DateTime.Parse("7/13/2009 1:00:00 PM");
Uri postUri = new Uri("http://firstname.lastname@example.org/private/full");
// Send the request and receive the response:
AtomEntry insertedEntry = service.Insert(postUri, entry);
Google provides extensive documentation and sample code, in a dazzling variety of languages. Even Objective-C for you Mac developers.
As with any scenario where the data can be updated from multiple locations, your application will have to implement synchonization logic. The items you upload one day could be deleted from the web or from the user’s iPhone before your next sync. But fortunately the sometimes daunting task of communicating with the remote service is trivial in this case.