Facebook: Unable to get users' birthday

Posted by Sarfraz on Stack Overflow See other posts from Stack Overflow or by Sarfraz
Published on 2010-05-05T08:05:41Z Indexed on 2010/05/05 8:08 UTC
Read the original article Hit count: 466

Hello All,

I have been trying hard for the last 5 hours or so to get the facebook users' birthday through facebook connect but I have not managed to do so. The same code worked previously and still works on other sites made earlier (old ones) but does not seem to work again. Here is the code:

require_once ('./connect/facebook.php');

$facebook = new Facebook("myapi", "mysecret");
$fbuser = $facebook->get_loggedin_user();

if ($fbuser)
{
    $_SESSION['custid'] = $fbuser;

    $fb_look_fields = array(
                            'name', 
                            'first_name', 
                            'last_name', 
                            'name', 
                            'timezone', 
                            'name', 
                            'sex', 
                            'birthday',
                            'birthday_date',
                            'current_location', 
                            'proxied_email',
                            'affiliations'
                            );

    try
    {
        $user_data = $facebook->api_client->users_getInfo($fbuser, $fb_look_fields);
    }
    catch (Exception $e)
    {
         echo $e->getMessage();
    }

    # for birth date
    $fb_birthday = $user_data[0]['birthday'];

    if (!$fb_birthday)
    {
        $fql_result_xml = $facebook->api_client->fql_query("SELECT birthday FROM standard_user_info WHERE uid = " . $fbuser);
        $fb_birthday = $fql_result_xml['birthday'];
    }

    echo $fb_birthday;

The birthday is always empty even though i have set it to visible to all.

  • I am using new facebook php client
  • I even tried getting info from standard table but without any luck

I would really appreciate your help and ideas.

Thanks

© Stack Overflow or respective owner

Related posts about php

Related posts about web-development