我使用Facebook 4.7 SDK和Graph Ver.2.5我没有得到用户朋友的详细信息
GraphRequest request = GraphRequest.newMeRequest(AccessToken.getCurrentAccessToken(),
new GraphRequest.GraphJSONObjectCallback() {
@Override
public void onCompleted(JSONObject jsonObject, GraphResponse graphResponse) {
if (jsonObject != null) {
try {
JSONObject friends = jsonObject.getJSONObject("friends");
JSONArray array = friends.getJSONArray("data");
for (int i = 0; i < array.length(); i++) {
JSONObject object = array.getJSONObject(i);
Toast.makeText(getApplication(),"...Name:" + object.getString("name"),Toast.LENGTH_SHORT).show();
Log.d("MyApp", "...ID:" + object.getString("id"));
Log.d("MyApp", "...Name:" + object.getString("name"));
}
} catch (JSONException e) {
e.printStackTrace();
}
}
}
});
可以有人给出facebook图api朋友列表的完整示例....
1 回答
除非他们向您的应用授予权限(user_friends),否则您无法获取用户的朋友 . 您只能获得用户朋友的数量 .