Retrieving a Public Feed
The first, and possibly simplest, way you’ll interact with the Google calendar API is to retrieve an XML feed for a public calendar. It's a great place to start because it involves one (sometimes two) simple HTTP get requests and no cookies or tokens. First, make sure the calendar you want to access is public. Once that's done, you should be able to access it through this simple function:
static void GetCalendarStream(void *pData)
GApp *pme = (GApp*)pData;
AEECLSID_WEB, (void **)&pme->pEventWeb);
CALLBACK_Init(&pme->clb, CalCallback, pme);
szPostHeader = MALLOC(200);
This is a fairly straightforward example of an IWEB GetResponse
call. You'll need to set the content type in the headers by hand. Google specs out the feed URL as follows:
In the previous example, you can see that you've looked up a non-existent email@example.com account. This example requests only public events (hence the "public" access level) and full details on all those events. To read calendars that have not been made public, you'll have to log in. You'll see more on that later.
Now that you've requested all this data, how do you receive it? The easiest thing to do is write it to a file. Listing 1 shows you how to capture it.
Make sure the connection was successful and then, using a basic readable loop, pull the data over the network connection and write it to a file. While this process is interesting, it provides limited opportunity for getting the feeds for public calendars. In order to achieve more interesting results, such as letting users add events to their calendar or request a private feed, you'll need to fix it so they can log into their Google Calendar account.