我正在寫一個PHP腳本,通過捲曲頁面處理的交易,所以我有一個函數來獲取和URL非空的字符串返回
function get_url($Url){
if (!function_exists('curl_init')){
die('Sorry cURL is not installed!');
}
set_time_limit (20);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $Url);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Cookie: age_gate_birthday=19901101"));
curl_setopt($ch, CURLOPT_REFERER, "http://www.facebook.com");
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2049.0 Safari/537.36");
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$output = curl_exec($ch);
return $output;
}
呼應$輸出在這個函數返回頁面後空總是返回HTML的字符串,但是如果我呼籲這個函數在另一個函數
function get_vid ($sql, $url) {
$data = get_url($url);
...
返回的值是一個空字符串儘管$輸出了值時GET_URL()在做它的事。
奇怪的是,該錯誤只存在於特定的URL中,但與其他人一起工作正常。
謝謝你試圖幫助!
更新:似乎CURL在特定鏈接上隨機返回FALSE,這似乎是這個問題的罪魁禍首,但curl_error是空的,所以我無法確定這個原因。
您可以發佈它的工作是不工作的URL和一個。 – SkaiBoa 2014-09-04 11:57:00
我已經將它追溯到cURL,爲特定的URL返回空字符串 - 例如,此網址適用於:http://www.escapistmagazine.com/videos/view/movie-defense-force/9631-Dungeons-Dragons-Wrath龍之神 - 令人震驚的忠實 - 電影 並且這不: A-Cop-That-Kills-People-CRAZY – beezischillin 2014-09-04 11:59:57