2

我正在使用 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);
        }

如何获取用户数据配置文件?谢谢!

4

1 回答 1

3

前提是您登录。

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
}
于 2012-05-28T21:49:01.507 回答