How to force abstract JSON data only from an API response?

Description

I’m trying to make a request to an API via PHP cURL

$access_token = $tokens['access_token'];
$headers = array(
  "Authorization: Bearer " . $access_token
  );

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,env('USER_INFO'));
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
curl_setopt($ch, CURLOPT_TIMEOUT_MS, 1000);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_VERBOSE, TRUE);
curl_setopt($ch, CURLOPT_ENCODING , "gzip");
curl_setopt($ch, CURLOPT_USERAGENT,'php');
curl_setopt($ch, CURLOPT_HTTPHEADER,$headers);
$info = curl_getinfo($ch);

$userInfo = curl_exec($ch);
$userInfo = json_decode($userInfo, true);

dd($userInfo);

I kept getting this back

{"sub":"acr:123;type=STAT","updated_at":1509463516,"name":"User","email":"user@email.com"}
1


Try #2

If I do

$userInfo = json_encode($userInfo, true);

I got

{"sub":"acr:123;type=STAT","updated_at":1509463516,"name":"User","email":"user@email.com"}
"true"


How do I get rid of the 1 or true below it, and only get the JSON data ?

Is there another param for json_decode() that I need to pass in ?


Questions

How would one go about and debug this further ?


I’m open to any suggestions at this moment.

Any hints/suggestions / helps on this be will be much appreciated!

For more info please click herehttps://stackoverflow.com/q/47141560

Have a question or need a custom quote?
info@smartinfocare.com