2014-09-22 53 views
0

我一直在通過cron作業從https nasa.gov網站請求一個kml文件。它已經工作了多年,剛剛開始失敗。我沒有收到任何捲曲錯誤 - 請求只是超時。美國國家航空航天局網站必須改變一些東西。捲髮請求失敗(超時)

$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); 
+3

如果你什麼也沒做,那麼也許美國國家航空航天局有,問他們\ – 2014-09-22 02:08:05

回答

0

事情必須與美國航空航天局的網站已經改變。

看起來他們正在使用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> 

你消耗的數據所有這些年沒有真實性的保證:)

這可能對您有用:How do I tell curl to follow HTTP redirects?

URL也可能已更改。但這是一個留給讀者的練習。