CURL在json加载文件上返回null

时间:2015-09-27 16:36:29

标签: php json curl

当我尝试在PHP中加载带有Curl的json文件时,我的代码返回 NULL !我做错了什么?我检查了我的phpinfo并启用了curl。

    // 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));

我的json文件:

{
    "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"
    }
}

感谢您的帮助......

0 个答案:

没有答案