0

我的要求是找到安装该应用程序的朋友列表。

在这里,我需要将输入作为应用程序 ID,基于此应用程序 ID,我需要获取已安装此应用程序的用户。

4

4 回答 4

6

比 avs099 的回答更快(单次调用):

/me/friends?fields=installed使用该应用程序的访问令牌(或/USER_ID/friends?fields=installed应用程序访问令牌)进行 API 调用

于 2012-05-14T15:19:34.673 回答
2

这相对容易:

  1. 使用https://graph.facebook.com/me/friends调用获取好友列表(您可以使用Graph API Explorer

  2. 对于每个朋友,获取他的 ID 并向以下 Graph API 发送请求:https ://graph.facebook.com/FRIEND_ID?access_token=APP_ID|APP_SECRET& fields=installed

注意:fields=installed是必需的,根据文档

如果你得到类似的东西

{“已安装”:真,“id”:“FRIEND_ID”}

这意味着该朋友已安装该应用程序。如果只是 ID 回来了 - 那么他没有安装应用程序。

APP_ID 和 APP_SECRET 可以在您的应用页面上找到。

希望有帮助。

于 2012-05-14T13:48:10.107 回答
0

我遇到了同样的问题,但在使用带有 FQL 的 Facebook API 时仍然有点模糊。Facebook FQL 页面几乎没有帮助,所以我继续写了一个快速的解决方案,供那些将来可能在这个问题上苦苦挣扎的人使用。

可以这么说,如果您使用的是 Facebook PHP SDK,那么长的 FQL 解决方案可以压缩成几行,这很高兴看到。 我的 Facebook API 解决方案

于 2012-08-14T18:15:44.753 回答
0

如果你使用考拉,你可以这样做

在控制器 user.rb

@user = User.all

在模型 user.rb

def friends_using_app
facebook { |fb| fb.get_connection("me", "friends?fields=installed") }
end

在视图中

 <% friends = current_user.friends_using_app %>
 <% friends_using_app = friends.find_all {|x| x['installed'] == true}    %>
 <% friends_id = friends_using_app.map {|x| x['id']}  %>
 <% show_friends = @user.find_all{|x| x[:uid] = friends_id} %>
 <% show_friends.each do |x| %>
 <%= image_tag x.avatar %>
 <% end %>
于 2014-01-08T22:34:11.033 回答