用户身份:
final Session session = Session.getActiveSession();
if (session != null && session.isOpened()) {
// If the session is open, make an API call to get user data
// and define a new callback to handle the response
Request request = Request.newMeRequest(session, new Request.GraphUserCallback() {
@Override
public void onCompleted(GraphUser user, Response response) {
// If the response is successful
if (session == Session.getActiveSession()) {
if (user != null) {
user_ID = user.getId();//user id
profileName = user.getName();//user's profile name
userNameView.setText(user.getName());
}
}
}
});
Request.executeBatchAsync(request);
}
user_ID
&profileName
是字符串。
对于访问令牌:
String token = session.getAccessToken();
编辑:(2014 年 13 月 1 日)
对于用户电子邮件(我没有通过在设备或模拟器上运行来检查此代码):
这些只是我的意见,或者你可以称之为建议
setReadPermissions(Arrays.asList("email", ...other permission...));
//by analyzing the links bellow, i think you can set the permission in loginbutton as:
loginButton.setReadPermissions(Arrays.asList("email", ...other permission...));
user.asMap().get("email");
欲了解更多信息,请参阅:
link1、link2、link3、link4、