使用oficial facebook-android-sdk获取用户个人资料facebook

时间:2012-05-28 21:38:18

标签: android facebook-android-sdk

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

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

1 个答案:

答案 0 :(得分: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
}