Ruby on Rails与Facebook集成 [英] Ruby on Rails integration with facebook
问题描述
我想将Facebook与我的Ruby on Rails应用程序集成. Facebook登录应该是在该网站上注册的唯一方法.
I want to integrate facebook with my Ruby on Rails application. the facebook login should be the only way to register on the site.
我需要从facebook上获取的信息是用户的姓名和个人资料图片.
The information I need to get from facebook is the name and the profile pictures of the users.
您建议我使用哪些gem/plugins? (我假设我将需要一个gem来进行身份验证,并需要一个gem来进行facebook集成)
What gems/plugins you suggest I use ? (I assume that I will need a gem for the authentication, and a gem for the facebook integration)
谢谢
奥德
推荐答案
在Omniauth的帮助下,我发现Devise相当有效.有了比我更多的耐心,您就可以使用Omniauth来完成工作.
I found Devise with the help of Omniauth fairly effective. With a little more patience than I have, you could get things working with just Omniauth.
您需要的设计版本位于GitHub上,从当前版本开始,您需要也是omniauth的github版本.
The devise version that you would need lives on GitHub, and as of the current version, you need a github version of omniauth as well.
来自我的gemfile:
From my gemfile:
gem 'devise', :git => 'https://github.com/plataformatec/devise.git'
#oath enables facebook login, for one
gem 'omniauth', :git => 'https://github.com/intridea/omniauth.git'
gem 'oa-oauth', :require => "omniauth/oauth"
#openid enables google login, and openid generally
gem 'oa-openid', :require => 'omniauth/openid'
这里有一个不错的教程,介绍了将Devise与Facebook结合使用的一种可能方法:
There's a decent tutorial on one possible way to use Devise with Facebook here: https://github.com/plataformatec/devise/wiki/OmniAuth:-Overview
Facebook将返回一个电子邮件地址,上面的链接中提供了示例代码;我想您也可以要求它提供个人资料图片,尽管我还没有探索授权API.
Facebook will return an email address with sample code provided in the link above; I presume you can ask it for a profile picture as well, though I haven't explored the authorization API much yet.
这篇关于Ruby on Rails与Facebook集成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!