my FB.login(function ends with scope as it should:
}, {scope:'user_birthday,friends_birthday'});
after the user logs in the function permissionsTest() fires:
function permissionsTest(){
FB.api('me/friends?fields=birthday', {fields:'birthday'}, function(response) {
alert(response.data[1]);
});
}
But all the alert returns is: [object Object] when I am trying to see something like: 12/09/1983
How should this work?
see: graph.facebook.com/me/friends?fields=birthday
You can clearly see that there is an object called "data" holding an array of objects called "id" and "birthday"
My previous attempts:
response.data[1] returns [object Object]
response returns [object Object]
response.data[1].id returns undefined
response.data[1].birthday returns undefined
response.id returns undefined
response.birthday returns undefined
I can't seem to get it right and I feel I have exhausted the docs, stack and google.
Some of the friends birthdays may be null. Check out the response with the Facebook Graph API Explorer:
{
"data": [
{
"birthday": "03/03",
"id": "997"
},
{
"id": "998"
},
{
"birthday": "05/06/1986",
"id": "999"
}
]
This was returning data for me:
FB.api('me/friends?fields=birthday', {fields:'birthday'}, function(response) {
for (var i = 0; i < response.data.length; i++) {
alert(response.data[i].birthday);
}
});