Created
March 14, 2012 11:20
-
-
Save cihann/2035850 to your computer and use it in GitHub Desktop.
google weather api
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$xml = simplexml_load_file('http://www.google.com/ig/api?weather=Melbourne'); | |
$information = $xml->xpath('/xml_api_reply/weather/forecast_information'); | |
$current = $xml->xpath("/xml_api_reply/weather/current_conditions"); | |
$conditions = $xml->xpath("/xml_api_reply/weather/forecast_conditions"); | |
echo $information[0]->city['data']; | |
echo $current[0]->temp_f['data']; | |
echo $current[0]->condition['data']; | |
foreach ($conditions as $cond) | |
{ | |
echo $cond->day_of_week['data']; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment