25
blog.mondragon.cc
Blackbook is a useful gem that mines all your contacts from services such as gmail, aol, hotmail and yahoo.
Example:
- require 'rubygems'
- require 'blackbook'
- aol = Blackbook.get :username => '<a href="mailto:me@aol.com">me@aol.com</a>', :password => 'whatever'
- gmail = Blackbook.get :username => '<a href="mailto:me@gmail.com">me@gmail.com</a>', :password => 'whatever'
- hotmail = Blackbook.get :username => '<a href="mailto:me@hotmail.com">me@hotmail.com</a>', :password => 'whatever'
- yahoo = Blackbook.get :username => '<a href="mailto:me@yahoo.com">me@yahoo.com</a>', :password => 'whatever'
- #contacts is an array of hashes with :name and :email keys, any other metadata
- #in the contacts are added as additional key/value pairs
- contacts = []
- # collect unique contacts by email address into an array
- (aol + gmail + hotmail + yahoo).each do |contact|
- contacts << contact unless
- contacts.detect{|c| contact[:email].downcase == c[:email].downcase }
- end
- # export as xml formatted text
- exporter = Blackbook::Exporter::Xml.new
- xml = exporter.export(contacts)
- # export to VCard formatted text
- exporter = Blackbook::Exporter::Vcf.new
- vcards = exporter.export(contacts)

