Created
January 16, 2012 20:50
-
-
Save danoc/1622983 to your computer and use it in GitHub Desktop.
Use SimpleXML and Google's (unofficial) Weather API to display the current temperature for a city.
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 | |
// Use SimpleXML and Google's (unofficial) Weather API | |
//to display the current temperature for a city. | |
$zip = 13902; // change to desired city | |
$weather = simplexml_load_file('http://www.google.com/ig/api?weather='.$zip); | |
$city = $weather->weather->forecast_information->city['data']; // city name | |
$degrees = $weather->weather->current_conditions->temp_f['data']; // current temperature | |
// display the current temperature and city name | |
echo $degrees."° - ".$city; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Google shut down their (unofficial) weather API, so this no longer works.