【发布时间】:2018-09-25 01:14:51
【问题描述】:
我正在尝试从此 URL 加载 Json 数组
到目前为止我尝试过的如下:
//By Using File_get_contents()
$insta_source = file_get_contents($url);
$insta_array = json_decode($insta_source, TRUE);
var_dump($insta_array);
//AND
//By Using php CURL
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
$server_output = curl_exec ($ch);
curl_close ($ch);
var_dump($server_output);
//As in output it gives "Bool(false)" (get_file_contents())
//Curl Error gives : "bool(true)" but not the json array
非常感谢, 吉姆
【问题讨论】:
-
你读过错误吗? 您无权查看此页面。
-
感谢您回来。我更新了我的问题,请查看。
-
我什至尝试过发布请求,它给出了 403 错误代码。你对此无能为力。
-
请再次检查我的问题,我已更新。在 CURL 中,它在添加其他参数后给了我“Bool(true)”。现在的问题是我们需要 Json Array 而不是 Bool
-
在
curl_close($ch);之前添加$httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);,看看响应码是什么。它是 403。您无法访问该页面。
标签: php file-get-contents php-curl