I'm requesting an access token from Facebook and the new response (since API v2.3) looks like this after using print_r($response);
:
PHP:
Array ( [{"access_token":"123","token_type":"bearer","expires_in":111}]
I tried $response[0]->access_token
and $response['access_token']
and both are returning nothing.
How to get the access_token value?
答案 0 :(得分:-1)
I think $response
looks like:
$response = array(
'{"access_token":"123","token_type":"bearer","expires_in":111}' => ""
);
Somehow you've set the JSON body of the response as the key.
You can still access the token but it's a bit weird:
$json_response = key($response);
$data = json_decode($json_response, false);
$token = $data["access_token"]; // "123"