Customize Google Calendar RSS Feeds: Sort Events, Limit Results, etc. [Tips & Tricks] | Posted at 2:21 PM
If you use an RSS reader to subscribe to people’s Google Calendar events, or you use an RSS parser to read your calendar’s feed onto a webpage, you may have realized that there’s not really any good documentation about customizing that feed. Well, actually, there IS but it’s not apparent from doing a simple Google search that you can use the Google Calendar API reference to see how to customize a feed display.
Today I wanted to do a couple things, I wanted to sort the RSS by start date and from the event happening soonest to the event happening later. I also wanted to limit the results to 5 to reduce time for parsing.
Here’s how to do it, it’s quite simple:
If you notice, all I did was add some query string values.
orderby: starttime – Order results by when they start
sortorder: ascending – Order from least to greatest (soonest to latest)
max-results: 5 – Limit results to 5 events
You can use the following query string keys to customize your RSS data: Google Calendar API Reference
Tip: If you’re using PHP and SimplePie to parse the RSS, you need to add the following line of code to prevent SimplePie from automatically sorting the items by date: