- can retrieve FB friend list of logged in user
- retrieving birthdays is a different deal
- gave KT to Manish :P
[Where do we go from here?] (https://www.youtube.com/watch?v=O9C0D1RGn2g)
- clone repository
- use
"python -m simpleHTTPServer"
to view demo - login using the FB button
- may have to refresh to see results #bug =======
Where do we go from here?
This is why we can't get all friends: https://developers.facebook.com/docs/apps/faq look for this question:
- In v2.0 of the API I'm unable to get the full friend list of someone who has logged into my app - is there a way to get the full friend list?
also relevant:
- This will only return any friends who have used (via Facebook Login) the app making the request from here.
another obstacle:
this is the code which would have solved our problem before FB got wise:
- code:
FB.api("/me/friends?fields=id,name,birthday,picture, link", function(response) {
var birthdays = response.data; //list of friend objects from facebook
var currentMonth = new Date().getMonth() + 1;
var upcoming = [];
for (var i = birthdays.length - 1; i >= 0; i--) {
item = birthdays[i];
if (item.birthday) {
var bday = item.birthday;
//if the birthday is after today
if (currentMonth <= bday.substr(0, 2) * 1 && new Date().getDate() <= new Date(bday).getDate()) {
upcoming.push(item);
}
}
};
//set the year to current year because of birth years being different.
var year = new Date().getFullYear();
upcoming = upcoming.sort(function(a, b) {
return new Date(a.birthday).setYear(year) - new Date(b.birthday).setYear(year);
});
console.log(upcoming);//console log here, but do whatever you want with the sorted friends
});
- page does not automatically display birthdays on successful user login. But works on refresh