开发者

Facebook Graph API & Koala: How to find relationship status of a user's 'friend'

开发者 https://www.devze.com 2023-03-26 07:12 出处:网络
I have built a rails app using Devise, Omniauth and Koala. With this I have been able开发者_如何学运维 to pull down all of the current user\'s friends:

I have built a rails app using Devise, Omniauth and Koala. With this I have been able开发者_如何学运维 to pull down all of the current user's friends:

  @graph = Koala::Facebook::GraphAPI.new(@token)
  @friends = @graph.get_connections("me", "friends")

and I have been able to get the current user's relationship status:

  @graph = Koala::Facebook::GraphAPI.new(@token)
  @relationship = @graph.get_object("me")

What I haven't been able to figure out is how to make a call for all of the current user's friends that also includes their relationship status. I think I need to include some incremental argument / parameter in the get_connections("me", "friends") call, but I don't know what that incremental argument parameter would be.

Inside my config/initializers/omniauth.rb file, I have included the following in the Facebook scope:

{:scope => 'publish_stream,offline_access,email,user_relationships,friends_relationships'}

Any help with this specific Koala question? Is there a list anywhere that shows a bunch of different examples of Koala and how to use it to make the various different calls of Facebook data?

Thanks in advance!


you need to get permission first

redirect_to session['oauth'].url_for_oauth_code(:permissions=>'friends_relationships')   
@graph.get_connections('me','friends',:fields=>"name,gender,relationship_status")


@graph.fql_query("select uid, relationship_status from user where uid in (select uid2 from friend where uid1 = me())"

make fql calls. They are much much faster to use in large numbers.

0

精彩评论

暂无评论...
验证码 换一张
取 消