Get user profile facebook using oficial facebook-android-sdk [closed]

隐身守侯 提交于 2019-12-11 00:30:10

问题


i am using facebook-android-sdk for a single sign on, but i can`t get user facebook profile data. this is my code:

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);
        }

How get user data profile? Thanks you!


回答1:


Provided that you logged in.

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

The request listener:

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
}


来源:https://stackoverflow.com/questions/10790671/get-user-profile-facebook-using-oficial-facebook-android-sdk

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!