Gov Weather XML数据馈送失败


Gov Weather XML data feed failing on me

在戳了一个小时之后,我卡住了。所有被注释掉的url都可以正常工作。但是政府数据失败了。任何想法吗?

//  $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;
}

读取文件类http://pastebin.com/8pQxfsz7

尝试使用cURL

我试了你的代码,它产生了这个错误。

file_get_contents (http://forecast.weather.gov/MapClick.php?lat=39.1666&朗= -86.5215,单位= 0,lg = english& FcstType = dwml):打开流失败:HTTP请求失败!HTTP/1.0 403 Forbidden

然后我看到了这个链接一切都很好。