drjun1994 2012-07-18 07:31
浏览 111

通过Facebook API获取用户的生日

I'm having some troubles with the Facebook API, I am requesting permission for some information of the user by Javascript:

FB.login(function (response) {
    if (response.authResponse) {
        // authorized
    } else {
        // canceled
    }
}, {scope: 'email,user_birthday,user_location'});

Now I want to get the user's information (when he is authorized) by PHP:

$facebookUser = json_decode(file_get_contents('https://graph.facebook.com/' . $this->data['userid'] . '?access_token=' . $this->oathtoken . '&fields=id,name,location,gender,email,picture,birthday,link'));

All working great, except that the API is not giving the user's birthday back. Even when I set my birthday privacy settings on public it won't show up.

So:

echo $facebookUser['birthday']; // Gives an error, since this key does not exists

Does somebody have an idea how to fix this?

  • 写回答

3条回答 默认 最新

  • douxian7808 2012-07-18 07:39
    关注

    You are logged in on the client side but php is executed on the server side so you receive only the basic information of an user object.

    If you logged in on the server side and have the permissions so you can get the birthday simply with:

    echo $facebookUser['birthday'];
    
    评论

报告相同问题?

悬赏问题

  • ¥15 做数电题要具体的步骤
  • ¥20 PDF元数据中的XMP媒体管理属性
  • ¥15 R语言中lasso回归报错
  • ¥15 网站突然不能访问了,上午还好好的
  • ¥15 有没有dl可以帮弄”我去图书馆”秒选道具和积分
  • ¥15 semrush,SEO,内嵌网站,api
  • ¥15 Stata:为什么reghdfe后的因变量没有被发现识别啊
  • ¥15 振荡电路,ADS仿真
  • ¥15 关于#c语言#的问题,请各位专家解答!
  • ¥15 这个如何解决详细步骤