facebook birthday api

Posted by mahmud ahsan on October 25, 2009 in FB Connect, Facebook | 4 Comments

fb_logoThere are many birthday related facebook application. Most of this type application provide feature like, they show you the upcoming birthdays of your friends. Some of the app also send notification to user before any birthday of his friends come.

Now I’ll show you the solution to get birthday of your friends using fql query or facebook api

Solution 1:
First you have to collect the uids (friends uid) of user and then get their info by api

   $friends = $_REQUEST['fb_sig_friends'];
   $userDetails = $facebook->api_client->users_getInfo($friends, 'last_name, first_name, uid, birthday');

  foreach($userDetails as $user){
     $birthday = $user['birthday']
  }

You can also use FQL Query to retrieve such information:

Solution 2:

   $friends = $_REQUEST['fb_sig_friends'];
   $query = "SELECT uid, first_name, last_name, birthday FROM user WHERE uid IN ($friends) ORDER BY birthday_date;

   $userDetails = $facebook->api_client->fql_query($query);
   foreach($userDetails as $user){
     $birthday = $user['birthday']
  }

So,  you can use any solution for your purpose. But remember, if any user don’t want to show his birthday to others using privacy options, then you never retrieve such user’s birthday.

Related Posts

If you think this article kicked ass, subscribe to the RSS feed or follow me on Twitter! Share with your friends, or leave a comment below (or better still, do both!)

Comments (4)

 

  1. Umair Jabbar says:

    good share :)

  2. Elric says:

    I have tried both solutions, but some of my friends birthday can’t be get. Then i try to check whether did he/she set privacy for the birthday, and i found out that he/she din’t set privacy for birthday.

    Is this kind of bug?

    • mahmud ahsan says:

      You have to ask your friend through your application to allow the birthdate extended permission. Until he allows that you couldn’t retrieve his birthday, whether he shows the birthday open in his profile.

  3. geolos says:

    or you may do it like:

    SELECT uid,name,birthday_date FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = *** user ***)

    -> where *** user *** should be replaced by you UID

Leave a Reply