Skip to content

Instantly share code, notes, and snippets.

@mattn
Created February 24, 2009 01:33
Show Gist options
  • Save mattn/69317 to your computer and use it in GitHub Desktop.
Save mattn/69317 to your computer and use it in GitHub Desktop.
require 'gdata';
require 'pit'
require 'rexml/xpath'
config = Pit.get("www.google.com", :require => {
"username" => "you email in google",
"password" => "your password in google"
})
gc = GData::Client::Contacts.new
gc.clientlogin(config['username'], config['password'])
xml = gc.get("http://www.google.com/m8/feeds/contacts/#{config['username']}/base").to_xml
addrs = []
REXML::XPath.each(xml, '//entry') { |x|
addrs.push( \
"#{REXML::XPath.first(x, 'title').text} " \
"<#{REXML::XPath.first(x, 'gd:email').attributes['address']}>" \
)
}
puts addrs.join(', ')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment