Apr 11, 2010
Weather forecast php application in 7 linesToday, I was looking for a way ( API etc )to get the current weather information for my application. And i found Yahoo! Weather. The Weather RSS feed provide weather information for your location. You can incorporate the RSS data into your application. The Weather RSS feed is a based on WOEID.
Preparing RequestFor the Weather RSS feed there are two parameters:
1. w for WOEID.
2. u for degrees units (Fahrenheit or Celsius).
WOEID indicates the location,
To find your WOEID, browse or search for your city from the Weather home page. The WOEID is in the URL for the forecast page for that city. For example, if you search for The Weather Channel New Delhi on the Weather home page, the forecast page for that city is http://weather.yahoo.com/india/delhi/new-delhi-2295019/. The WOEID is 2295019.
Our ApplicationIn our application we are fetching the data from the Yahoo! Weather RSS, with help of cURL. And will show the response by parsing SimpleXMLElement
//init cURL $ch = curl_init('http://weather.yahooapis.com/forecastrss?w=20070458&u=c'); // We need data in return
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $output = curl_exec(
); //parsing data $xml = new SimpleXMLElement($output); echo '<h1>'.$xml->title.'</h1>'; echo ($xml->item->description);
ResultThe result look like this -
Don't miss Google's Secret Weather API.
If this article helped you and you are feeling very Thankful. You can send me Bitcoins
By : Motyar+ @motyar