Question

I can successfully get the contacts from google using OAuth gem in rails. my gmail configuration is :

:google=>{
    :key=>"***",
    :secret=>"***",
    :expose => true, 
    :scope=>"https://www.google.com/m8/feeds/" 
  }

now i want to get contact from yahoo and hot mail. How to get that contact I have given following configuration in my oauth_consumer.rb file

:yahoo=>{
   :client=>:oauth_gem, 
   :expose => true, 
   :allow_login => true, 
   :key=>"**",
   :secret=>"**",
   :scope=>"https://me.yahoo.com"
 }

:hotmail=>{
   :client=>:oauth_gem, 
   :expose => true, 
   :allow_login => true, 
   :key=>"**",
   :secret=>"**"  
 }

when i am trying to do same like what is done in google it gives error like undefined methoddowncase' for nil:NilClass`

I have also tried contacts gem but fail to load contacts.

Was it helpful?

Solution

Please try to use OmniContacts https://github.com/Diego81/omnicontacts this will help you alot.

  1. In your gemfile

    gem "omnicontacts"
    
  2. Create config/initializers/omnicontacts.rb

    require "omnicontacts"
    
    Rails.application.middleware.use OmniContacts::Builder do
      importer :gmail, "client_id", "client_secret", {:redirect_path => "/oauth2callback", :ssl_ca_file => "/etc/ssl/certs/curl-ca-bundle.crt"}
      importer :yahoo, "consumer_id", "consumer_secret", {:callback_path => '/callback'}
      importer :hotmail, "client_id", "client_secret"
      importer :facebook, "client_id", "client_secret"
    end
    
  3. Create an app to yahoo https://developer.apps.yahoo.com/projects

    This will ask to verify your domain. So, just change your domain of localhost:3000 to local.appname.com:3000 or prefer your live server... (change host in local --- sudo gedit /etc/hosts)

  4. in your controller

      @contacts = request.env['omnicontacts.contacts']
      @user = request.env['omnicontacts.user']
      puts "List of contacts of #{user[:name]} obtained from #{params[:importer]}:"
      @contacts.each do |contact|
        puts "Contact found: name => #{contact[:name]}, email => #{contact[:email]}"
      end
    
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top