My code below return NULL when I try to load a json file with Curl in PHP ! What I did wrong ? I check my phpinfo and curl is enabled.
// set HTTP header
$headers = array(
'Content-Type: application/json'
);
$url = 'http://www.mywebsite.com/json.json';
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_URL, $url);
$result = curl_exec($ch);
curl_close($ch);
// DUMP
var_dump(json_decode($result, true));
My json file :
{
"0": {
"temps": "09:03:09",
"temps_bonus": "-00:16:00",
"ordre": 1,
"numero": "10",
"ecart": ""
},
"1": {
"temps": "09:15:19",
"temps_bonus": "-00:17:00",
"ordre": 2,
"numero": "7",
"ecart": "00:12:10"
}
}
Thanks for your help...