如何通过Facebook API获得生日? [英] How to get birthday via Facebook API?

查看:106
本文介绍了如何通过Facebook API获得生日?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在设置一个Facebook登录名,并成功获取了 first_name email 等内容.但是,我似乎无法弄清楚如何过生日.如果我要求如下所述的 birthday ,则不会返回任何内容.

I am setting up a Facebook login, and am successfully getting things like first_name, email, etc. However, I cannot seem to figure out how to get birthday. If I call for birthday as below, nothing returns.

FB.api('/me', {fields: 'birthday'}, function(response) {
  console.log(JSON.stringify(response));
})

如果我按如下所示调用 user_birthday ,则会收到此错误:"error":{"message":(#100)尝试访问不存在的字段(user_birthday)

If I call user_birthday as below, I get this error: "error":{"message":"(#100) Tried accessing nonexisting field (user_birthday)

FB.api('/me', {fields: 'user_birthday'}, function(response) {
  console.log(JSON.stringify(response));
})

我该怎么做?

推荐答案

由于您未发布登录代码且未提及权限,因此我假设您忘记了一件重要的事情:使用 user_birthday 权限.

Since you did not post your login code and you did not mention permissions, i assume you forgot one important thing: Authorizing with the user_birthday permission.

FB.login(function(response) {
    if (response.authResponse) {
        //user authorized the app
    }
}, {scope: 'user_birthday', return_scopes: true});

user_birthday 是权限, birthday 是字段的名称.如果仍然无法正常工作,则很可能没有设置生日.不确定是否需要.

user_birthday is the permission, birthday is the name of the field. If it still doesn´t work, then there is most likely no birthday set. Not sure if it is required.

例如: http://www.devils-heaven.com/facebook-javascript-sdk-login/

这篇关于如何通过Facebook API获得生日?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆