问题
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