0

I am getting the following back from an API:

{"status": 200, "msg": "Successfully authenticated", "data": {"token": xxxxx", "token_expiration_datetime": "2022-08-26T17:38:11.515215"}}

And I need to get the token response in a variable to post else where. when I use: 'json_decode $data' I am getting the following back:

200Successfully authenticatedArray

The way I have done this previously is to use $output_decode=json_decode($data, true) and then extract($output_decode, EXTR_PREFIX_SAME, "clash");

It's probably something really simple but I am very rusty and trying to finish up so I can go on vacation! Any ideas.

If I use var_dump($output_decode); I am getting the following:

array(3) {
  ["status"]=>
  int(200)
  ["msg"]=>
  string(26) "Successfully authenticated"
  ["data"]=>
  array(2) {
    ["token"]=>
    string(128) "xxxxx"
    ["token_expiration_datetime"]=>
    string(26) "2022-08-26T17:56:18.857176"
  }
}

So I guess the query is how to I get the token from the second array back to a variable?

saxopete
  • 1
  • 1

0 Answers0