Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the best way to access Google Calendar from ruby?

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.

like image 310
Jakub Hampl Avatar asked May 21 '10 03:05

Jakub Hampl


1 Answers

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
like image 92
Jakub Hampl Avatar answered Oct 20 '22 16:10

Jakub Hampl