php - Easiest way to get birthday info of all friends through graph api?


I am looking for the least resource intensive way of getting all friends' birthday information by a given user object Id. Probably using Event Object since birthdays of friends are visible inside events.




I've done something similar in the following way:

1) Like Awais pointed out - you need to first get the extended permission from the user at the time of login to access their birthday information

<fb:login-button perm="user_birthday, friends_birthday"></fb:login-button>

2) There are different ways of doing this, but if you are not using php sdk, you can get the friends birthday as follows

all_friends_profile = json_decode(file_get_contents(',name,birthday_date+from+user+where+uid+in+(select+uid2+from+friend+where+uid1%3Dme())&format=json&access_token=...'));

foreach($all_friends_profile as $profile)
   echo $profile->name.' birthay='.$profile->birthday_date;                  

Just replace the access token in the above code and it should loop through all your friends and print their birthdays

3) Basically the query I have used is

select uid,name,birthday_date from user where uid in (select uid2 from friend where uid1=me())

Good luck




quite easy.Just take extended permission of user birthday then just query user table to get birtday

<fb:login-button perm="user_birthday, friends_birthday"></fb:login-button>
foreach($user[data] as $friend)
    $fql    =   "select name, birthday_date from user where uid=".$friend['id'];
    $param  =   array(
                'method'    => 'fql.query',
                'query'     => $fql,
                'callback'  => ''
            $fqlResult   =   $facebook->api($param);


Hope it will work

People are also looking for solutions to the problem: php - debugging cakephp with netbeans - no variables


Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.