I have some code which is quite simple, it looks to query an API using CURL and return the json response.
Here is the code:
<?php
...[VARIABLES]...
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_PROXY, $proxy);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$result = curl_exec($ch);
var_dump($result);
?>
Here is the response:
string(310) "{"totalPages":0,"firstPage":true,"lastPage":true,"numberOfElements":0,"number":0,"totalElements":0,"columns":{"columnIds":["metrics/visits:::0","metrics/visitors:::2","metrics/timespentvisit:::4"]},"summaryData":{"totals":[2740.0,1384.0,241.4753313696613]},"oberonRequestXML":[null],"oberonResponseXML":[null]}"
I'm struggling to understand why the string(310) is being shown at the front of the json response, since I am expecting a JSON response only.