使用Facebook的官方公报,Android的SDK获取用户的个人资料的Facebook [关闭]

2019-09-17 13:45发布

我使用Facebook的Android的SDK的签收单上,但我不能老是让用户的Facebook个人资料数据。 这是我的代码:

try {
            JSONObject me = new JSONObject(facebook.request("me"));
            String id = me.getString("id");
            String name = me.getString("name");
            System.out.println("Id: " + id + "  ---- " + name);
        }catch(Exception ex) {
            System.out.println(ex);
        }

如何获得用户数据资料? 谢谢!

Answer 1:

只要你登录。

AsyncFacebookRunner myAsyncRunner = new AsyncFacebookRunner(facebook);
myAsyncRunner.request("me", new meRequestListener());

请求监听器:

public class meRequestListener implements RequestListener() {

    @Override
    public void onComplete(String response, Object state) {
        //response is your JSON response
    }

    //You also have to override all the other methods
}


文章来源: Get user profile facebook using oficial facebook-android-sdk [closed]