Skip to content

Instantly share code, notes, and snippets.

@cihann
Created March 14, 2012 11:20
Show Gist options
  • Save cihann/2035850 to your computer and use it in GitHub Desktop.
Save cihann/2035850 to your computer and use it in GitHub Desktop.
google weather api
<?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