[英]Curl request failing (times out)
我一直在從https nasa.gov網站通過cron作業請求kml文件。 它已經工作了很多年,現在才開始失敗。 我沒有任何卷曲錯誤-請求只是超時。 美國國家航空航天局(NASA)站點的某些內容必須已更改。
$curl_connection =
curl_init("http://firms.modaps.eosdis.nasa.gov/active_fire/kml/USA_contiguous_and_Hawaii_24h.kml");
//set options
curl_setopt($curl_connection, CURLOPT_CONNECTTIMEOUT, 20);
curl_setopt($curl_connection, CURLOPT_USERAGENT,
"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)");
curl_setopt($curl_connection, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl_connection, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl_connection, CURLOPT_FOLLOWLOCATION, true);
curl_setopt( $curl_connection, CURLOPT_SSL_VERIFYHOST, 0);
//perform our request
$string = curl_exec($curl_connection);
//show information regarding the request
print_r(curl_getinfo($curl_connection));
echo curl_errno($curl_connection) . '-' .
curl_error($curl_connection);
//close the connection
curl_close($curl_connection);
美國國家航空航天局(NASA)站點的某些內容必須已更改。
看來他們現在正在使用HTTPS:
$ curl http://firms.modaps.eosdis.nasa.gov/active_fire/kml/USA_contiguous_and_Hawaii_24h.kml
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>302 Found</title>
</head><body>
<h1>Found</h1>
<p>The document has moved <a href="https://firms.modaps.eosdis.nasa.gov/active_fire/kml/USA_contiguous_and_Hawaii_24h.kml">here</a>.</p>
</body></html>
這些年來,您在沒有真實性保證的情況下使用了該數據:)
這可能對您有用: 如何告訴curl遵循HTTP重定向? 。
URL可能也已更改。 但這是留給讀者的練習。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.