卷曲请求失败(超时)

时间:2014-09-22 02:04:53

标签: php curl https kml

我一直在通过https nasa.gov网站的cron作业请求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);

1 个答案:

答案 0 :(得分: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?

网址也可能已更改。但这是一项留给读者的练习。

相关问题