Skip to content

asadali/bdayhack

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 

Repository files navigation

STATUS

  • 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)

INSTALLATION

  • 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?

RANTS

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
});

KNOWN BUG LIST

  • page does not automatically display birthdays on successful user login. But works on refresh

About

playing around with fb graph api and some homies

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published