0
我正在使用以下代碼來獲取Facebook朋友的人數。但我只得到id
作爲迴應。Facebook圖api:未退回FriendsList數據
GraphRequest getFriendsCountRequest = GraphRequest.newGraphPathRequest(
fbToken,
"/me",
new GraphRequest.Callback() {
@Override
public void onCompleted(
GraphResponse response) {
// Application code
try {
System.out.println(response.getJSONObject().toString());
Long friendsCount = response.getJSONObject()
.getJSONObject("friends")
.getJSONObject("summary")
.getLong("total_count");
System.out.println("Total Friends: " + friendsCount);
} catch (JSONException e) {
Log.e(LoggedInActivity.class.getCanonicalName(), "Error in getting count from response", e);
}
}
});
Bundle parameters = new Bundle();
parameters.putString("fields", "friends");
getFriendsCountRequest.setParameters(parameters);
getFriendsCountRequest.executeAsync();
當使用圖形瀏覽器我得到/me/fields=friends
請幫忙預期的響應!
添加'facebookLoginButton.setReadPermissions( 「user_friends」); LoginButton解決了這個問題。 –