Over a million developers have joined DZone.

Add A Friend's Calendar On Google Calendar

·
This code shows how to add a friend's calendar to our Google Calendar account. 


require 'rubygems'
require 'mechanize'

agent = WWW::Mechanize.new
page = agent.get('https://www.google.com/accounts/ServiceLogin')
form = page.forms.first
form.Email = "user@gmail.com"
form.Passwd = "mypassword"
page2 = agent.submit(form)
page3 = agent.get("http://www.google.com/calendar")
secid = page3.header['set-cookie'].match(/secid=(.*),/)[1]

data = {
  "cid" => "23489dfskj12342gh34kj32434@group.calendar.google.com",  
  "hl" => "en",
  "lact" => "ADD",
  "ltyp" => "0",
  "secid" => secid,
}  
agent.post("http://www.google.com/calendar/editcallist", data)
Topics:

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}