Gov Weather XML 数据源在我身上失败
Gov Weather XML data feed failing on me
戳了一个小时后,我卡住了。所有注释掉的网址都可以正常工作。政府数据失败了。有什么想法吗?
// $url = 'http://en.wiktionary.org/w/api.php?format=json&action=query&titles=work&rvprop=content&prop=revisions&redirects=1';
$url = "http://forecast.weather.gov/MapClick.php?lat=39.1666&lon=-86.5215&unit=0&lg=english&FcstType=dwml";
//$url = 'http://www.reddit.com/r/bloomington/.rss';
//$url = "http://forecast.weather.gov/MapClick.php?lat=34.12699&lon=-118.27381&unit=0&lg=english&FcstType=dwml";
$myReadAccess=new ReadFile($url);
if(!$data=$myReadAccess->getFileContents()){
//ERROR, DISPLAY ERROR MESSAGE
echo "Error: " . $myReadAccess->getError();
}
else{
//SUCCESS, DISPLAY FILE CONTENTS
echo $data;
}
读取文件Class
http://pastebin.com/8pQxfsz7
尝试使用 cURL
我试过你的代码,它产生了这个错误。
file_get_contents(http://forecast.weather.gov/MapClick.php?lat=39.1666&lon=-86.5215&unit=0&lg=english&FcstType=dwml):
failed to open stream: HTTP request failed! HTTP/1.0 403 Forbidden
然后我发现了这个link
一切正常。
希望对您有所帮助..
戳了一个小时后,我卡住了。所有注释掉的网址都可以正常工作。政府数据失败了。有什么想法吗?
// $url = 'http://en.wiktionary.org/w/api.php?format=json&action=query&titles=work&rvprop=content&prop=revisions&redirects=1';
$url = "http://forecast.weather.gov/MapClick.php?lat=39.1666&lon=-86.5215&unit=0&lg=english&FcstType=dwml";
//$url = 'http://www.reddit.com/r/bloomington/.rss';
//$url = "http://forecast.weather.gov/MapClick.php?lat=34.12699&lon=-118.27381&unit=0&lg=english&FcstType=dwml";
$myReadAccess=new ReadFile($url);
if(!$data=$myReadAccess->getFileContents()){
//ERROR, DISPLAY ERROR MESSAGE
echo "Error: " . $myReadAccess->getError();
}
else{
//SUCCESS, DISPLAY FILE CONTENTS
echo $data;
}
读取文件Class http://pastebin.com/8pQxfsz7
尝试使用 cURL
我试过你的代码,它产生了这个错误。
file_get_contents(http://forecast.weather.gov/MapClick.php?lat=39.1666&lon=-86.5215&unit=0&lg=english&FcstType=dwml): failed to open stream: HTTP request failed! HTTP/1.0 403 Forbidden
然后我发现了这个link 一切正常。
希望对您有所帮助..