Borsn Borsn - 3 years ago 204
PHP Question

Getting protected values from object Facebook API (PHP)

How to get the protected values from the object below FB returns in their API?

Facebook\Authentication\AccessToken Object
(
[value:protected] => AAAAAAA
[expiresAt:protected] => DateTime Object
(
[date] => 2017-11-30 19:27:26.000000
[timezone_type] => 3
[timezone] => UTC
)

)


I tried like this:
$var->value
or
$var->expiresAt->date
but doesn't work.

Answer Source

The Facebook API encapsulates its properties, so you need to use the getters. For example, you can get the expiresAt property with the getter:

var_dump($accessToken->getExpiresAt()->format("d/m/Y H:i:s")); // string(19) "30/11/2017 16:43:11"

The same goes for value and the rest of the properties.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download