1. 程式人生 > >QueryList The received content is empty!

QueryList The received content is empty!

使用QueryList3.0的時候的時候報錯了 The received content is empty!

這個報錯內容其實是沒有收到正確的URL,只需要稍微修改一下即可

1.開啟 QueryList.php 大約在 285 行 找到  private function _request($url) 這個方法。

2.修改程式碼: 其實就是在curl訪問完之後如果返回的result為false 則用 get方法請求資料

//修改前--------------------------------   
 /**
     * URL請求
     * @param $url
     * @return string
     
*/ private function _request($url) { echo "<pre>"; if(function_exists('curl_init')){ $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false
); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_AUTOREFERER, true); curl_setopt($ch, CURLOPT_REFERER, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.71 Safari/537.36');
$result = curl_exec($ch); curl_close($ch); }elseif(version_compare(PHP_VERSION, '5.0.0')>=0){ var_dump(2); $opts = array( 'http' => array( 'header' => "Referer:{$url}" ) ); $result = file_get_contents($url,false,stream_context_create($opts)); }else{ $result = file_get_contents($url); } return $result; } //修改後 /** * URL請求 * @param $url * @return string */ private function _request($url) { echo "<pre>"; if(function_exists('curl_init')){ $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_AUTOREFERER, true); curl_setopt($ch, CURLOPT_REFERER, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.71 Safari/537.36'); $result = curl_exec($ch); if(!$result){$result = file_get_contents($url);} curl_close($ch); }elseif(version_compare(PHP_VERSION, '5.0.0')>=0){ var_dump(2); $opts = array( 'http' => array( 'header' => "Referer:{$url}" ) ); $result = file_get_contents($url,false,stream_context_create($opts)); }else{ $result = file_get_contents($url); } return $result; }

3.修改完畢之後上傳更新程式碼,直接執行搞定!