[英]Facebook SDK for android - getting access token by passing username and password
[英]Android Facebook SDK - username is getting null
我正在使用简单的facebbok将Facebook集成到我的应用程序中。我需要将Facebook用户名发送到server。但是我从配置文件列表器中获得了用户名null。 这是我的代码
public void loginToFacebook(View v){
mSimpleFacebook.login(this);
}
OnLoginListener listner = new OnLoginListener() {
@Override
public void onLogin() {
mSimpleFacebook.getProfile(onProfileListener);
}
};
OnProfileListener onProfileListener = new OnProfileListener() {
@Override
public void onComplete(Profile profile) {
System.out.println(profile.getUsername());//getting null here
}
};
我也尝试过使用代码
OnLoginListener listner = new OnLoginListener() {
@Override
public void onLogin() {
Profile.Properties properties = new Profile.Properties.Builder()
.add(Properties.USER_NAME)
.add(Properties.ID)
.build();
mSimpleFacebook.getProfile(properties, onProfileListener);
}
};
但是在这种情况下,列表器不会被解雇。
这是我在Application类中给予的许可
private void configureFacebook() {
Permission[] permissions = new Permission[] {
Permission.USER_ABOUT_ME,
Permission.PUBLIC_PROFILE,
Permission.READ_STREAM,
Permission.EMAIL,
Permission.PUBLISH_ACTION
};
SimpleFacebookConfiguration configuration = new SimpleFacebookConfiguration.Builder()
.setAppId(Constants.FB_APPID)
.setNamespace("namespace")
.setPermissions(permissions)
.build();
SimpleFacebook.setConfiguration(configuration);
}
您无法在API v2.0中获取用户名
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.