2015-12-22 46 views
1

我使用Facebook SDK 4.x,我需要得到具有名好友列表,但我不能得到它, 我也實現了這個graph API獲取Facebook的好友列表與名稱

new GraphRequest(
AccessToken.getCurrentAccessToken(), 
"/me/friend", 
null, 
HttpMethod.GET, 
new GraphRequest.Callback() { 
    public void onCompleted(GraphResponse response) { 
     /* handle the result */ 
    } 
} 
).executeAsync(); 

,這是我reponse

response {Response: responseCode: 200, graphObject: {"summary":{"total_count":3},"data":[]}, error: null} 

我沒有得到名稱的朋友列表,如果你有任何想法比PLZ給我。 在此先感謝。

+0

的Facebook只返回誰已授權您的應用程序的朋友列表。所以它必須爲每個朋友安裝您的應用程序。 – Skynet

+0

我可以得到朋友的名字嗎? –

+3

@MohitSuthar看看這個http://stackoverflow.com/questions/29491479/fetch-friends-list-from-facebook-sdk-4-0-1-in-android-with-graph-api-2- 2答案 – Hardy

回答

2

我的解決方案使用此

new GraphRequest(
      AccessToken.getCurrentAccessToken(), 
      "/me/taggable_friends", 
      null, 
      HttpMethod.GET, 
      new GraphRequest.Callback() { 
       public void onCompleted(GraphResponse response) { 
        Log.e("getFriendsDat",""+ response); 
       } 
      } 
    ).executeAsync(); 

你將會得到一個名字和細節的好友列表。
你必須添加user_friends許可,並需要提交您的應用程序進行審覈。

0

首先,it's /me/friends,不/me/friend。話雖這麼說,你只能得到訪問授權誰你的App也與user_friends許可朋友。響應意味着你有3個朋友,但他們沒有授權您的應用user_friends

的更多信息:Get ALL User Friends Using Facebook Graph API - Android

+0

如果任何朋友授權我的應用程序比我獲得他的名字?您可以在我的回答中閱讀 –

+0

,朋友必須使用user_friends授權您的應用 – luschn