0

我正在使用简单的 facebbok将 facebook 集成到我的应用程序中。我需要将 facebook 用户名发送到服务器。但是我从个人资料列表中获得了用户名为空。这是我的代码

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

但在这种情况下,listner 不会被解雇。

这是我在 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);
}
4

1 回答 1

2

您无法在 API v2.0 中获取用户名

于 2014-06-21T14:54:47.840 回答