私は公園に関するページを作成しています。各公園について、緯度/経度があり、ほとんどの公園のために、私はYahooの天気予報APIYahoo天気の特定の米国緯度/経度の場所でエラーが発生する
を使用することができていますが、何らかの理由で、一部のページが、このようなエラーを返す:
無効な入力/ forecastrssのw? =私はYahooの天気APIに次のように作るコールの後に2347563
:
http://www.geomojo.org/cgi-bin/reversegeocoder.cgi?long=-121.433098&lat=40.509312
私はエラーのこれらの種類を解決することができますどのように任意のアイデア?ここで
は私のコードです:ここでは
$url = 'http://www.geomojo.org/cgi-bin/reversegeocoder.cgi?long='.$lng.'&lat='.$lat;
// Calls the url to get the zip code and woeid
$webpage = file_get_contents($url);
//echo $webpage;
try
{
$xml = new SimpleXMLElement($url, 0, true);
// Gets the woeid to look up the weather in that specific place dynamically.
$woeid= $xml->woeid; // Displays "Text"
$zip = $xml->name; // Displays "Text"
// URL to send to yahoo weather to get weather RSS
$yahoo_url = 'http://weather.yahooapis.com/forecastrss?w='.$woeid;
$xml = file_get_contents($yahoo_url);
$yahoo_response = new SimpleXMLElement($xml , 0, false);
$weather_description = $yahoo_response->channel->item->description;
$splitdata = explode('<a', $weather_description);
echo '<p>'.$splitdata[0].'</p>';
}
catch (Exception $e)
{
echo 'Caught exception: ', $e->getMessage(), "\n";
}
が、これは動作しません例のURLです。左側の天候のセクションを参照してください:
http://www.comehike.com/outdoors/parks/park.php?park_id=86