views:

438

answers:

2

I'm building a webapp that manages certain types of events for users. I want to provide a way to display those events inside of a user's google calendar.

What I was really hoping for was a way to publish my own google calendar compatible feed and allow users to subscribe to it, like they can subscribe to "interesting calendars". So that if events change or new events are added, they are reflected in their calendar. But it looks like google only lets users import calendar data in ical or csv formats, not in atom feed format.

The problem is, existing events in my webapp can change and new events are added. I want those changes to immediately be reflected in google calendar. And I can't expect a user to keep reimporting an ICAL file. The following SO question is extremely similar, but doesn't really have an answer posted: http://stackoverflow.com/questions/920486/generate-a-google-calendar-compatible-feed

Am I going about this the wrong way? Do I need to be using the gdata API to create a calendar and publish events to it? It seems like publishing an atom feed would be much simpler, but if google can't subscribe to an atom feed, that won't work.

If I simply publish my events as an ICAL file, will google calendar reread the URL regularly and update the data? Some users my have 4 or 5 events each day, so the file will just keep getting bigger and bigger as time goes on. It really seems like this isn't a good solution.

+2  A: 

Looking at other sites that do this, it would seem that google does re-read external calendars in ical format regularly.

It then's up to you to trim the ical feed you provide e.g by killing dates in the past.

So to solve your problem:

  • generate a ical file and serve from your web site
  • get your users to subscribe to it in Google Calendar
  • regularly refresh the ical file, trimming old data

Example headers & start of ics file from TripIt.com, where this seems to work well:

curl -v http://..../tripit.ics

< HTTP/1.1 200 OK
< Server: nginx
< Date: Fri, 29 Jan 2010 21:53:58 GMT
< Content-Type: text/calendar; charset=utf-8
< Transfer-Encoding: chunked
< Connection: close
< Expires: Fri, 29 Jan 2010 22:08:58 GMT
< Cache-Control: private
< 
BEGIN:VCALENDAR
X-WR-CALNAME:Malcolm Box (TripIt)
X-WR-CALDESC:TripIt Calendar
X-PUBLISHED-TTL:PT15M
PRODID:-//John Papaioannou/NONSGML Bennu 0.1//EN
VERSION:2.0

BEGIN:VEVENT ...

Malcolm Box
Tauren
I've just tried it with TripIt - got the webcal:// link (to an ics file), added it to Google. Then added another event at tripit.com, went back to google and it was immediately shown.
Malcolm Box
Thanks Malcolm! This looks very promising. I was hoping to only have to provide an ics feed to support google calendars, iphone, ical, outlook, and so forth. If its working for tripit, then I should be able to get it working too.
Tauren
A: 

Looks like to reliably update the google calendar you have to use the API: http://code.google.com/apis/calendar/data/2.0/developers_guide.html although I'll bet from a pragmatic point of view, if you have an ical file that updates reasonably often, you will get decent performance.

Aerik
Aerik, I agree -- using the gdata API is probably the most reliable way. But it won't help with iPhone, iCal, Outlook, and other users. I may end up going with gdata eventually, but if an ics feed can be reliably used in google, I'll try it first.
Tauren