2016-05-12 201 views
0

我有一个用户的Facebook ID,我可以从它的个人资料中获取信息,例如我的android应用程序中的名称?如何通过用户id获取Facebook用户信息android

+0

检查以下答案:http://stackoverflow.com/a/15647007/5828664,它完全和很好的解释。 – Amesys

+0

试试这个http://stackoverflow.com/questions/37183258/how-to-get-email-from-facebook-sdk-4-0/37183573#37183573 –

回答

0

我只是发现了解决方案:

GraphResponse response = new GraphRequest(
     AccessToken.getCurrentAccessToken(), 
     "/" + id, 
     null, 
     HttpMethod.GET, 
     new GraphRequest.Callback() { 
      public void onCompleted(GraphResponse response) { 
      } 
     } 
    ).executeAndWait(); 

    JSONObject json = response.getJSONObject(); 
    try { 
     String name = json.getString("name"); 
    }catch(JSONException e){ 
     e.printStackTrace(); 
    } 
相关问题