如何通过用户ID android获取facebook用户信息

时间:2016-05-12 20:29:40

标签: android facebook

我有用户的脸书ID,我可以从其个人资料中获取信息,例如我的Android应用程序中的名称吗?

1 个答案:

答案 0 :(得分: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();
    }
相关问题