Sohail Bahadur

Whatever you do, do your work heartily, as for the Lord rather than for men. [Colossians 3:23]

Google Weather API (Weather Forecast)

Posted on : Friday, May 18, 2012

Google WeatherGoogle Weather API is being used to get weather information, in this tutorial we will learn how do we implement it using PHP and ASP Classic.




API URL
http://www.google.com/ig/api?weather=[city name or zip code]&hl=[language]

e.g.
http://www.google.com/ig/api?weather=Karachi&hl=ur
http://www.google.com/ig/api?weather=London&hl=en

API URL return XML file which contain the following information.



<xml_api_reply version="1">
<weather module_id="0" tab_id="0" mobile_row="0" mobile_zipped="1" row="0"
section="0">

<forecast_information>
<city data="Karachi, Sindh"/>
<postal_code data="karachi"/>
<latitude_e6 data=""/>
<longitude_e6 data=""/>
<forecast_date data="2012-05-18"/>
<current_date_time data="1970-01-01 00:00:00 +0000"/>
<unit_system data="US"/>
</forecast_information>

<current_conditions>
<condition data="Cloudy"/>
<temp_f data="86"/>
<temp_c data="30"/>
<humidity data="Humidity: 62%"/>
<icon data="/ig/images/weather/cloudy.gif"/>
<wind_condition data="Wind: SW at 18 mph"/>
</current_conditions>

<forecast_conditions>
<day_of_week data="Fri"/>
<low data="81"/>
<high data="93"/>
<icon data="/ig/images/weather/mostly_sunny.gif"/>
<condition data="Mostly Sunny"/>
</forecast_conditions>

<forecast_conditions>
<day_of_week data="Sat"/>
<low data="79"/>
<high data="93"/>
<icon data="/ig/images/weather/mostly_sunny.gif"/>
<condition data="Mostly Sunny"/>
</forecast_conditions>

<forecast_conditions>
<day_of_week data="Sun"/>
<low data="79"/>
<high data="93"/>
<icon data="/ig/images/weather/mostly_sunny.gif"/>
<condition data="Mostly Sunny"/>
</forecast_conditions>

<forecast_conditions>
<day_of_week data="Mon"/>
<low data="79"/>
<high data="95"/>
<icon data="/ig/images/weather/mostly_sunny.gif"/>
<condition data="Mostly Sunny"/>
</forecast_conditions>

</weather>
</xml_api_reply>

Posted by : sohail | Category : Tutorial | Comments (15)

© Copyright Chris Logix 2011
Sohail Bahadur (barcode)
Resume in Microsoft Word Format Resume in Acrobat pdf Format
Valid XHTML 1.0 Transitional Valid CSS!