2014-09-22 124 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也可能已更改。但这是一个留给读者的练习。