我正在尝试从这个URL获取一些
JSON数据:
$url = 'http://site.com/search.PHP?term=search term here'; $result = json_decode ( file_get_contents($url) );
但是,客户端的webhost已禁用allow_url_fopen设置,因此上述代码不起作用.
喜欢这个:
原文链接:https://www.f2er.com/php/132684.html$url = 'http://site.com/search.PHP?term=search term here'; $rCURL = curl_init(); curl_setopt($rCURL,CURLOPT_URL,$url); curl_setopt($rCURL,CURLOPT_HEADER,0); curl_setopt($rCURL,CURLOPT_RETURNTRANSFER,1); $aData = curl_exec($rCURL); curl_close($rCURL); $result = json_decode ( $aData );