【发布时间】:2011-06-09 05:26:25
【问题描述】:
您好,我正在尝试从 json 文件中获取内容,但我做不到有很多麻烦,我的代码是:
<?PHP
$url = 'http://www.taringa.net/api/efc6d445985d5c38c5515dfba8b74e74/json/Users-GetUserData/apptastico';
$ch = curl_init();
$timeout = 0; // set to zero for no timeout
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$file_contents = curl_exec($ch); // take out the spaces of curl statement!!
curl_close($ch);
var_dump($file_contents);
?>
如果我将地址放在浏览器中,我可以毫无问题地获取内容,但是如果我尝试在 PHP 或其他代码上获取它,我会遇到问题,我该怎么办?我尝试使用 file_get_contents();也是,但我什么也没得到,只有问题和问题
【问题讨论】:
-
定义术语问题
-
是的,我得到:403 - 禁止
标签: php json api curl file-get-contents