How to get the fields value from Facebook Token Meta Data Response?

Facebook SDK to Login with Facebook for my Website:
$accessToken = YOUR_ACCESS_TOKEN;
$fb = new Facebook\Facebook([
    'app_id' => fbAppId,
    'app_secret' => fbSecret,
    'default_graph_version' => 'v2.2',
    ]);
$oAuth2Client = $fb->getOAuth2Client(); 
$tokenMetadata = $oAuth2Client->debugToken($accessToken);
echo "<pre>";print_r($tokenMetadata);

By using the above code, I get the following response. How can I get the get the fields value from this array.

Facebook\Authentication\AccessTokenMetadata Object
(
    [metadata:protected] => Array
        (
            [app_id] => APP_ID
            [application] => APP_NAME
            [expires_at] => DateTime Object
                (
                    [date] => 2016-04-09 10:19:12
                    [timezone_type] => 3
                    [timezone] => UTC
                )

            [is_valid] => 1
            [issued_at] => DateTime Object
                (
                    [date] => 2016-02-09 10:19:12
                    [timezone_type] => 3
                    [timezone] => UTC
                )

            [scopes] => Array
                (
                    [0] => email
                    [1] => publish_actions
                    [2] => public_profile
                )

            [user_id] => USER_ID
        )

)

To fetch all of the metadata use below funcation:


$expiresAt = (array)$tokenMetadata->getField('expires_at');//pass fields name

$expiresDate = $expiresAt['date'];

 

Share on Google+Share on FacebookTweet about this on TwitterEmail this to someone