![](/img/trans.png)
[英]how to get mutual friends between two friends using graph api v2.2 android sdk
[英]Facebook Graph API v2.2 me/friends only returns no. of users
好的,首先,我已经访问了StackOverflow上的所有相关问题,但找不到答案。 因此,请勿将此标记为类似问题的重复项。
我正在使用最新的Graph API v2.2来获取正在使用我的应用程序的FB朋友的列表。
请求Android代码-
Session activesession=Session.getActiveSession();
if(activesession!=null){
new Request(
activesession,
"/v2.2/me/friends",
null,
HttpMethod.GET,
new Request.Callback() {
@Override
public void onCompleted(Response response) {
// TODO Auto-generated method stub
String strresponse=response.getRawResponse();
JSONObject jsonresponse=null;
try {
jsonresponse = new JSONObject(strresponse);
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
).executeAsync();
}
else{
System.out.println("Session is NULL");
}
}
响应-{“数据”:[
],“ summary”:{“ total_count”:199}}
我肯定知道我的FB朋友列表中有一个朋友,该朋友下载了相同的应用程序并通过FB登录到该应用程序。
我也尝试过使用FB Graph资源管理器工具进行类似的操作,它给了我相同的响应-
我期望数据数组中至少有一个用户详细信息。 不知道我在这里想念什么。
请指教。
谢谢!
试试这个me / taggable_friend instend of me / friend希望它能起作用
会话activesession = Session.getActiveSession(); if(activesession!= null){new Request(activesession,“ /v2.2/me/taggable_friend”,null,HttpMethod.GET,new Request.Callback(){@Override public void onCompleted(Response response){// TODO自动生成的方法存根String strresponse = response.getRawResponse(); JSONObject jsonresponse = null;试试{jsonresponse = new JSONObject(strresponse);
} catch(JSONException e){// TODO自动生成的catch代码块e.printStackTrace(); }}}).executeAsync();
} else {System.out.println(“ Session is NULL”); }}
谢谢
尝试像这样在Facebook v2.2
Bundle bundle = new Bundle();
bundle.putString("fields", "name,picture,id");
new Request(session, "/me/friends", bundle, HttpMethod.GET, new Callback() {
@Override
public void onCompleted(Response response) {
System.out.println("response=============="+response);
}
}).executeAsync();
尝试这个
public void getFriends() {
Session activeSession = Session.getActiveSession();
if (activeSession.getState().isOpened()) {
new Request(
activeSession,
"/me/friends",
null,
HttpMethod.GET,
new Request.Callback() {
public void onCompleted(Response response) {
GraphObject graphObject = response.getGraphObject();
if (graphObject != null) {
try {
JSONObject jsonObject = graphObject.getInnerJSONObject();
JSONArray data = jsonObject.getJSONArray("data");
for (i = 0; i < data.length(); i++) {
final String name = data.getJSONObject(i).getString("name");
final String id = data.getJSONObject(i).getString("id");
}
} catch (JSONException e) {
e.printStackTrace();
}
}
}
}
).executeAsync();
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.