我可以使用OAuth gem在google中成功获取谷歌的联系人。我的gmail配置是:
:google=>{
:key=>"***",
:secret=>"***",
:expose => true,
:scope=>"https://www.google.com/m8/feeds/"
}
现在我想通过雅虎和热门邮件联系。如何获得我在oauth_consumer.rb文件中给出以下配置的联系
: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=>"**"
}
当我尝试像谷歌中所做的那样做时,它为nil提供错误like undefined method
downcase':NilClass`
我也尝试了contacts gem但无法加载联系人。
答案 0 :(得分:2)
请尝试使用OmniContacts https://github.com/Diego81/omnicontacts,这将对您有所帮助。
在你的gemfile中
gem "omnicontacts"
创建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
为雅虎https://developer.apps.yahoo.com/projects
创建应用这将要求您验证您的域名。所以,只需将localhost:3000
的域名更改为local.appname.com:3000
或者更喜欢您的实时服务器...(在本地更改主机--- sudo gedit / etc / hosts)
@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
答案 1 :(得分:1)
如果有人遇到Yahoo OAUTH身份验证问题,如果您收到了access_token但很难将请求发送到yahoo API或使用yahoo YQL。我在这里创建了一个详细的文档: