简体   繁体   English

无法从facebook获取user_birthday

[英]cannot get user_birthday from facebook

I having problem in the scenario of getting user_birthday from the Facebook, I have tried many solution and i found that i cannot get extra info from the first authentication logIn so I've created another request for getting user birthday and i tried many accepted solution like this one but i still cannot get user email and the birthdate even when i tried to get age_range which is included in public_profile got nothing 我在从Facebook获取user_birthday的场景中遇到问题,我尝试了许多解决方案,但发现无法从第一次身份验证登录中获取额外信息,因此我创建了另一个获取用户生日的请求,并尝试了许多接受的解决方案,例如这一,但即使我尝试获取public_profile中包含的age_range,我仍然无法获得用户电子邮件和生日

and the facebook user is marked the birthdate as public i tried using sociauth library but with no success same problem 和facebook用户被标记为生日,我尝试使用sociauth库公开,但没有成功相同的问题

just i can get user birthday when im using my account which is the dev of the app 我可以在使用我的帐户(应用程序的开发人员)时获得用户生日

finally i used loginbutton which is not my preferred scenario with permission 最终我使用了loginbutton ,这不是我许可的首选方案

 authbutton.setReadPermissions(Arrays.asList("public_profile","user_birthday"));

the wired thing is i can now get email without adding email permission but still get null with the birhtday and age_range 有线的事情是我现在可以在不添加电子邮件许可的情况下获取电子邮件,但在birhtday和age_range仍然为null

this is my loginbutton code 这是我的登录按钮代码

authbutton=(LoginButton) findViewById(R.id.authButton);
    authbutton.setReadPermissions(Arrays.asList("public_profile","user_birthday"));
      // session state call back event
      authbutton.setSessionStatusCallback(new Session.StatusCallback() {
       @Override
       public void call(Session session, SessionState state, Exception 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) {
                                  if (user != null) {
                                   Log.i("tag","User ID "+ user.getId());
                                   Log.i("tag","Email "+ user.asMap().get("email"));
                                   lable.setText(user.getBirthday().toString());
                                  }
                              }
                          }).executeAsync();

              }

       }
     });

Thanks in advance 提前致谢

lable.setText(user.asMap().get("birthday").toString());

May be try this way? 可以这样尝试吗?

The app id and the FB id you login to test should be of the same account. 您登录以测试的应用程序ID和FB ID应该使用相同的帐户。 Else it will return null.. 否则它将返回null。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM