-1

I am trying to get the users' birthday via

$.getJSON("https:graph.facebook.com/me?fields=birthday&access_token="+accessToken, function(data) {
    });

But unfortunately I have no idea on how to get the birthday itself because it gives me back this huge Object were I don't know how to handle it:

Could anyone please help me. I was looking at similar questions but unfortunately making the $.getJSON synchronous as suggested here is deprecated. The questions here and here did not really help either. Thanks in advance :)

Community
  • 1
  • 1
janjackson
  • 351
  • 2
  • 11

1 Answers1

1

To get the birthday in your code, you need navigate into Objects of your JSON data.

`$.getJSON("https://graph.facebook.com/me?fields=birthday&access_token="+accessToken, function(data) {
    var birthday = data.birthday // This is your birthday
    var id = data.id // This is your Fb ID

    console.log('Hi! '+ id +'. Your birthday is '+ birthday)
});`
Rui Costa
  • 800
  • 4
  • 13