我正在编写一个程序,其中我想user's basic information
Id
,Name
,Email
,Birthday
,{{1}等等。
我成功Locale
这些详细信息:Id,Name,Locale
但fetched
获取时间:电子邮件&生日
检查下面的代码:
getting null
现在我private static final List<String> PERMISSIONS = Arrays.asList("public_profile", "email", "user_location", "user_birthday");
String get_id, get_name, get_gender, get_email, get_birthday, get_locale, get_location;
............................................................
loginBtn = (LoginButton) findViewById(R.id.authButton);
loginBtn.setUserInfoChangedCallback(new UserInfoChangedCallback() {
@Override
public void onUserInfoFetched(GraphUser user) {
if (user != null) {
userName.setText("Hello, " + user.getName());
userInformation.setText(buildUserInfoDisplay(user));
} else {
userName.setText("You are not Logged In");
userInformation.setText("");
}
}
});
}
private String buildUserInfoDisplay(GraphUser user) {
StringBuilder userInfo = new StringBuilder("");
userInfo.append(String.format("First Name: %s\n\n", user.getFirstName()));
userInfo.append(String.format("Last Name: %s\n\n", user.getLastName()));
userInfo.append(String.format("Birthday: %s\n\n", user.getBirthday()));
userInfo.append(String.format("Email: %s\n\n", user.getProperty("email")));
userInfo.append(String.format("Locale: %s\n\n", user.getProperty("locale")));
return userInfo.toString();
}
:
名字: getting
姓氏: Kim
生日: DSouza
电子邮件: null
区域设置: null
答案 0 :(得分:0)
Hye我发现了问题,这个问题非常小,只需在您的活动中使用它:
private Session.StatusCallback callback = new Session.StatusCallback() {
@Override
public void call(Session session, SessionState state,
Exception exception) {
onSessionStateChange(session, state, exception);
if (session.isOpened()) {
Log.i(TAG,"Access Token"+ session.getAccessToken());
Request.newMeRequest(session,
new Request.GraphUserCallback() {
@Override
public void onCompleted(GraphUser user,Response response) {
}
});
答案 1 :(得分:0)
您可以使用
获取电子邮件ID,生日对于电子邮件:
String email = user.getProperty("email").toString();
生日:
String birth =user.getBirthday()