Failed to get user birthday via Facebook

I am trying to get a Facebook user’s birthday via Facebook Connect, but I haven’t succeeded. The same code worked earlier and still works on other sites made earlier (old), but doesn't 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 if I set it to for everyone .

  • I am using the new PHP PHP client
  • I even tried to get information from a standard table, but with no luck

Has Facebook updated its API / policy? Or what am I missing / not working correctly in the code?

+3
source share
3 answers

Facebook . ? , .

+2

standard_user_info access_token. . , , "4 1999 ".

+1
source

Source: https://habr.com/ru/post/1744110/


All Articles