Facebook 好友请求 - 失踪好友
Facebook Friends Request - Missing Friends
我请求从我正在开发的 Android 应用程序中获得用户朋友。从 Facebook Api V2.0 开始,我知道我应该只获得已经通过我的应用程序登录的用户朋友。但是,尽管我知道用户的某些朋友已通过我的应用程序登录,但在请求该用户的朋友时,他们不会出现在 Facebook 请求响应中。例如,我找回了 40 个朋友,而不是 50 个以上。
有没有人经历过这种行为?我已经删除了一些用户的应用程序以通过登录重新授权它,但我没有看到行为有任何变化。
这是我使用的代码:
new Request(ParseFacebookUtils.getSession(),"me/friends", null, null, new Request.Callback(){
@Override
public void onCompleted(Response response) {
if (response == null){
return;
}
else if (response.getError() != null){
response.getError().getException().printStackTrace();
return;
}
GraphMultiResult result = response.getGraphObjectAs(GraphMultiResult.class);
List<GraphObject> fbInList = result.getData();
if (fbInList != null && !fbInList.isEmpty()){
for (GraphObject user : fbInList) {
JSONObject jsonUser = user.getInnerJSONObject(); // The Facebook User
System.out.println("name: " + jsonUser.optString("name"));
}
}
}
}).executeAsync();
doc 中与您相关的部分是
In v2.0 of the API I'm unable to get the full friend list of someone who has logged into my app - is there a way to get the full friend
list?
With Graph API v2.0 and above, calls to /me/friends
return only the
friends who also use your app. These friends must have also granted
the user_friends
permission. In the cases where you want to let people
tag their friends in stories published by your app, you can use the
Taggable Friends API. If you want to invite people to your app, we
have a number of solutions that depend on the type of app you've built
and the platforms you've built for. Please see our question about
Inviting Friends for more information.
因此,除了使用您的应用程序的朋友之外,他们还应该授权 user_friends
否则您将无法获得他们的详细信息。你做到了吗?
我找到问题所在了。当我更新到最新的 Facebook SDK 时,Facebook 仅返回 25 个好友。我需要使用分页功能或为我的好友请求添加限制。在以前的 SDK 上我不需要。
添加限制:
Bundle params = new Bundle();
params.putString("limit", "50"); // Up to 5000?
friendRequest.setParameters(params);
相关堆栈溢出问题:
Facebook graph API 'friends' request now only returning 25 friends per page? What's going on?
有用的 Facebook link 用于分页:
https://developers.facebook.com/docs/graph-api/using-graph-api/v2.2#paging
我请求从我正在开发的 Android 应用程序中获得用户朋友。从 Facebook Api V2.0 开始,我知道我应该只获得已经通过我的应用程序登录的用户朋友。但是,尽管我知道用户的某些朋友已通过我的应用程序登录,但在请求该用户的朋友时,他们不会出现在 Facebook 请求响应中。例如,我找回了 40 个朋友,而不是 50 个以上。
有没有人经历过这种行为?我已经删除了一些用户的应用程序以通过登录重新授权它,但我没有看到行为有任何变化。
这是我使用的代码:
new Request(ParseFacebookUtils.getSession(),"me/friends", null, null, new Request.Callback(){
@Override
public void onCompleted(Response response) {
if (response == null){
return;
}
else if (response.getError() != null){
response.getError().getException().printStackTrace();
return;
}
GraphMultiResult result = response.getGraphObjectAs(GraphMultiResult.class);
List<GraphObject> fbInList = result.getData();
if (fbInList != null && !fbInList.isEmpty()){
for (GraphObject user : fbInList) {
JSONObject jsonUser = user.getInnerJSONObject(); // The Facebook User
System.out.println("name: " + jsonUser.optString("name"));
}
}
}
}).executeAsync();
doc 中与您相关的部分是
In v2.0 of the API I'm unable to get the full friend list of someone who has logged into my app - is there a way to get the full friend list?
With Graph API v2.0 and above, calls to
/me/friends
return only the friends who also use your app. These friends must have also granted theuser_friends
permission. In the cases where you want to let people tag their friends in stories published by your app, you can use the Taggable Friends API. If you want to invite people to your app, we have a number of solutions that depend on the type of app you've built and the platforms you've built for. Please see our question about Inviting Friends for more information.
因此,除了使用您的应用程序的朋友之外,他们还应该授权 user_friends
否则您将无法获得他们的详细信息。你做到了吗?
我找到问题所在了。当我更新到最新的 Facebook SDK 时,Facebook 仅返回 25 个好友。我需要使用分页功能或为我的好友请求添加限制。在以前的 SDK 上我不需要。
添加限制:
Bundle params = new Bundle();
params.putString("limit", "50"); // Up to 5000?
friendRequest.setParameters(params);
相关堆栈溢出问题:
Facebook graph API 'friends' request now only returning 25 friends per page? What's going on?
有用的 Facebook link 用于分页:
https://developers.facebook.com/docs/graph-api/using-graph-api/v2.2#paging