简体   繁体   English

如何在Rails中使用OmniAuth来结识我的Facebook朋友?

[英]How to get my Facebook friends with OmniAuth in Rails?

I have a simple Rails app where I can log in with using Facebook through OmniAuth. 我有一个简单的Rails应用程序,可以通过OmniAuth使用Facebook登录。

Is there any way to obtain my Facebook friends with using OmniAuth Facebook gem? 有什么方法可以使用OmniAuth Facebook gem来获得我的Facebook朋友? Do I need to use any other gems for that? 我需要使用其他宝石吗? (if so, which ones are the best ones - the most updated/etc). (如果是这样,哪个是最好的-最新/等)。

You can also use the koala gem which works well Facebook graph api. 您也可以使用效果很好的Facebook图形api的考拉宝石

@graph = Koala::Facebook::API.new(oauth_access_token)
friends = @graph.get_connections("me", "friends")

Try using gem 'fb_graph' for it. 尝试使用gem'fb_graph'。 Check the link for it https://github.com/nov/fb_graph 检查链接https://github.com/nov/fb_graph

You can get your fb friends by 您可以通过以下方式获得您的fb朋友

@fb_friends = FbGraph::User.me(USER-FB-ACCESS-Token).friends

Here, USER-FB-ACCESS-Token is the access token that one user will will get after connecting to facebook via omniauth facebook. 在这里, USER-FB-ACCESS-Token是一个用户通过omniauth facebook连接到facebook后将获得的访问令牌。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM