使用file_get_contents将JSON转换为PHP无效

时间:2019-12-03 04:11:52

标签: php json

我的api json

{"success":true,"result":{"id":"1017fw436","title":"Leading with NLP","author":"David","url":"abc.com","image":"/abc.img","info":{"pages":"258 Pages","year":"2001","size":"2.74 MB","downloads":"151,185 Downloads","language":"English"},"url_url":"https://drive.google.com/file/d/1GDA9N9SQLHdXBKih8c_GEwcUL"}}

我用过

    <?php $json_url = "my link api";
$json = file_get_contents($json_url);
$data = json_decode($json, TRUE);
echo $data['id'];
?>

但这不起作用

1 个答案:

答案 0 :(得分:0)

请检查Link

尝试以下代码行:

file_get_contents("http://example.com", false, ['ignore_errors' => true]);
var_dump($http_response_header);