Parsing the Google Calendar XML Feed

We use Google's Calendar as part of our church web page. It's easy to keep up to date and we don't have to install any special calendar software on our server. It even has an extremely sophisticated XML feed. OK, the feed is considerably shorter, if you tweak the call a bit, using Google's published parameters. You can use this feed in an RSS aggregator, informing your readers about what's happening in the near future. But this might not be exactly what you want.

For instance: It's helpful to have a web-page listing of upcoming events, or a customized RSS feed.

This turns out to be relatively easy to do, if you know the trick, with a bit of PHP code. Let me say right off the top that I didn't come up with the PHP code myself, I got it from P.J. Cabrera, and it's available under what looks to be a pretty open license.

So I used Cabrera's script as the starting point to construct to scripts:

The scripts are fully, possibly painfully, annotated, so you can see exactly what I did at every step. I'm not going to discuss them here, then, but you can add comments in the the parallel blog post to this page, and I'll address them there.

Now you'd think I could just provide a link to each of the two annotated pages, and you'd get the annotated pages. This turns out not to be the case. The server will execute the PHP code on each page, and then ship XML. Don't believe me? Load up the web page and/or the RSS Feed and look at the source code. You won't find the PHP code, just perfectly formed XHTML or XML.

So I've put both scripts in this

tar file, parse_google_calendar.tar

(Sorry, my free web page server prohibits ZIP files.)

Download the file, and you can extract both the html page, to create a calendar listing, and the php page, to create an RSS feed.

A few things to note:

Put all comments in the parallel blog post.


Current URL: http://www.rcjhawk.us/software/gcal/index.html

        Go Back to My Homegrown Software Page        Valid XHTML 1.0!