views:

138

answers:

2

I'm writing an app for a company that uses Google Calendar internally and would need to use events they already have in their calendar in the app. So I need to get read only access to their calendars from the app (namely I need the events title, start and end dates and attendee emails for all future events).

What is the simplest way to do this in ruby (I would need it to work relatively seamlessly on Heroku)?

I tried using the GCal4Ruby gem which seemed the least outdated of the ones I found but I'm unable to even authenticate through the library (HTTPRequestFailed - Captcha required error) let alone get the info I need.

Clarification: What I'm talking about is the Google Apps version of the calendar, not the one at calendar.google.com.

+1  A: 

You should be able to use the Google Calendar private xml address feature to pull out the needed data.

You could then parse it with hpricot or nokogiri to extract whatever fields you need.

Mike Buckbee
Sadly that doesn't seem to be supported in the Google Apps version. Though that would be ideal.
Jakub Hampl
The domain admin for your Google Apps setup should be able to enable this -> [instructions](http://groups.google.com/group/google-calendar-help-howto/msg/bd4b7416102d5950)
Mike Buckbee
Does that have other security implications?
Jakub Hampl
Well, everything has security implications, so "yes". Without a doubt it is security through obscurity (don't share the URL); but it doesn't seem wildly irresponsible with the data either.
Mike Buckbee
I'll try to get hold of the admin (though probably after the weekend) and update what can be done. Thanks for the help.
Jakub Hampl
A: 

OK I got the api via GCal4Ruby working. I'm not exactly sure what went wrong the first time. Thanks to Mike and James for their suggestions. This is sample code I used for anyone interested:

require "rubygems"
require "gcal4ruby"

serv = GCal4Ruby::Service.new
serv.authenticate "[email protected]", "password"

events = GCal4Ruby::Event.find serv, {'start-min' => Time.now.utc.xmlschema, 
    :calendar => 'example-cal%40example.com'}

events.each do |event|
    puts event.title
    puts event.attendees.join ", "
    puts event.start_time
    puts event.end_time
    puts '-----------------------'
end
Jakub Hampl