facebook birthday api

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.

mahmud ahsan

Computer programmer and hobbyist photographer from Bangladesh, lives in Malaysia. My [Github | Business | Twitter | Linkedin | Youtube | Instagram | 500px]

You may also like


  • Umair Jabbar
    October 25, 2009 at 2:54 pm

    good share 🙂

  • Elric
    May 27, 2010 at 3:10 pm

    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
      mahmud ahsan
      May 27, 2010 at 4:01 pm

      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.

  • geolos
    June 20, 2010 at 2:38 pm

    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

  • Rahul Kadukar
    October 11, 2010 at 1:02 am

    Sorry for sounding like a noob, I do not understand from where we have to execute these, could you please guide me in the right direction


  • Ghulfam
    January 17, 2011 at 6:13 pm

    $friends = $_REQUEST[‘fb_sig_friends’];

    how get this parameter???

    $userDetails = $facebook->api_client->users_getInfo($friends, ‘last_name, first_name, uid, birthday’);

    where is define class and functions
    please reply with links

    • mahmud ahsan
      mahmud ahsan
      January 17, 2011 at 11:02 pm

      Old post. Skip it and instead use graph api to get friends. checkout facebook documentation.

      • Ozan Dikerler
        February 25, 2011 at 5:56 pm

        Could you please share again how can we get the birthdays with graph api

        • mahmud ahsan
          mahmud ahsan
          February 25, 2011 at 6:57 pm

          If you don’t find birthday api using graph api system, just call REST api using the new php sdk.

  • Manoj
    June 22, 2011 at 1:03 pm

    Hello mahmud Sir,

    I have an application which shows logged in users friends upcoming birthday, i have made it by using graph api javascript sdk, so it works very well before some days, but suddenly it stops to work from before 10 to 15 days without any change in application , so i have tried to trace it, but i didnt get any bug in the application, and funniest thing is, it works for one of my dummy id(friend count – 52) and not works for my original id(friend count – 255) – plz help me if you known to this issue.

    • mahmud ahsan
      mahmud ahsan
      June 23, 2011 at 12:04 am

      May be facebook changed something, someday ago publish stream was buggy and facebook recently updated that. I suggest to check facebook documentation if they updated something or not.

  • yogesh
    May 5, 2012 at 11:17 am

    I am using java-facebook api . I am not familiar with php .so please anyone can help me to find the similiar way to get friends birthday through java (rest api).

  • Krishna Karki
    May 23, 2012 at 4:34 pm

    Thanx for post..

    How can i get friend having their birthday today…

    I have to show friend on different different list. like..

    Today( Ram , Hari Sita etc)
    Tommarow (Raju, John, Roddy etc)

Comments are closed here.