Hi i'm trying to get the data from a JSON file from a url using Curl and PHP with this code:
<?php
// Initiate curl
$url = "https://panel.virtualcenter360.es/home/api/getdatasample?dateIni=1376524800&dateEnd=1381795200";
$ch = curl_init($url);
// Set the url
curl_setopt($ch, CURLOPT_URL,$url);
// Execute
$result=curl_exec($ch);
$res = iconv('UTF-8', 'UTF-8//IGNORE', utf8_encode($result));
var_dump(json_decode($res, true));
switch (json_last_error()) {
case JSON_ERROR_NONE:
echo ' - No errors';
break;
case JSON_ERROR_DEPTH:
echo ' - Maximum stack depth exceeded';
break;
case JSON_ERROR_STATE_MISMATCH:
echo ' - Underflow or the modes mismatch';
break;
case JSON_ERROR_CTRL_CHAR:
echo ' - Unexpected control character found';
break;
case JSON_ERROR_SYNTAX:
echo ' - Syntax error, malformed JSON';
break;
case JSON_ERROR_UTF8:
echo ' - Malformed UTF-8 characters, possibly incorrectly encoded';
break;
default:
echo ' - Unknown error';
break;
}
curl_close($ch);
?>
I'm getting the No errors message, but a NULL result. What do you think that could be the problem?
Maybe I need to configure some parameters from Curl?
Thanks!