Question: facebook api php birthday object get date


facebook api php birthday object get date

Answers 1
Added at 2016-12-30 08:12

I know this is silly question to ask but from permission i have been able to get birthday of user.

Facebook will returning an object now problem is i can't get that date value from it.

Can you please some one guide me.

permissions i have asked for

public $permissions = ['email', 'user_about_me', 'user_birthday', 'user_location', 'user_hometown'];

        Facebook\GraphNodes\Birthday Object
            [hasDate:Facebook\GraphNodes\Birthday:private] => 1
            [hasYear:Facebook\GraphNodes\Birthday:private] => 1
            [date] => 1994-07-05 00:00:00.000000
            [timezone_type] => 3
            [timezone] => Europe/Berlin

How can i get date here ?

I have tried but no success

`$bdayObj = $payload['birthday'];

Code: I have created Facebook_Auth class and using method like this

    public function getLoggedInUser()
        $user_req_arr = ['id','name','birthday','currency','email','locale','location'];
        $response     = $this->fb->get('/me?fields=' . implode(",", $user_req_arr), $this->AccessToken);
        $user         = $response->getGraphUser();
        return $user;

Worked with below solution: getting array like

    [id] => xxxxxxxxx
    [name] => xxxx xxxxxxxxxxxx
    [birthday] => xx/xx/xxxx
    [currency] => Array
            [currency_offset] => xxx
            [usd_exchange] => x.xxxxx
            [usd_exchange_inverse] => xx.xxxxx
            [user_currency] => xx

    [email] => xxxxx@xxx.xx.xx
    [locale] => en_GB
    [location] => Array
            [id] => xxxxxxxxxx
            [name] => xxxxxxx, xxxxxx

Answers to

facebook api php birthday object get date

nr: #1 dodano: 2016-12-30 08:12

Try to decode Responce :


It will gives you multidimensional array

and then you can access it like

$payload['birthday']['date']; or $payload['birthday']['timezone_type'];

Hope This will help thanks :)

Source Show
◀ Wstecz