How to get a birthday via Facebook API?

I set up Facebook login and successfully get things like first_name, emailetc. However, I cannot figure out how to get a birthday. If I call birthday, as shown below, nothing returns.

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

If I call user_birthday, as shown 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));
})

How to do it?

+5
source share
2 answers

Since you did not publish your login code and did not specify permission, I assume that you have forgotten one important thing: authorization by permission user_birthday.

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

user_birthday - , birthday - . , , , . , .

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

+14

://I.stack.imgur.com/3MLyV.jpg)

0

Source: https://habr.com/ru/post/1625352/


All Articles