So I am trying to store a value of the response but I don't know how. After I print_r()
the array I get the following:
stdClass Object
(
[user_id] => id number
[access_token] => access token code
[token_type] => BEARER
)
My question is how do I for example set a variable to the access_token? Like this:
$access_token = $array['access_token'] ?
It's not an array, it's an object (see the first line of the print_r()
output). To access an object property, you use ->
, not []
:
$access_token = $array->access_token;
You can also convert your object to an array like this
$array = json_decode(json_encode($your_object), true);