Skip to content

Instantly share code, notes, and snippets.

@mindreframer
Created June 7, 2013 15:20
Show Gist options
  • Save mindreframer/5730042 to your computer and use it in GitHub Desktop.
Save mindreframer/5730042 to your computer and use it in GitHub Desktop.
Read your contacts from gmail with ruby
# gem install contacts
# >> remove "require 'jcode' " in gdata gem, if on ruby 1.9
require 'rubygems'
require 'contacts'
CONTACTS_SCOPE = 'http://www.google.com/m8/feeds/'
CONTACTS_FEED = CONTACTS_SCOPE + 'contacts/default/full/?max-results=1000'
@client = GData::Client::Contacts.new
@client.clientlogin("[email protected]", "MY_PASS")
feed = @client.get(CONTACTS_FEED).to_xml; nil
# make it pretty :)
formatter = REXML::Formatters::Pretty.new
formatter.compact = true
puts formatter.write(feed.root,"")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment