$location = isset($_GET['location']) ? $_GET['location'] : '02135'; //get xml from google api $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'http://www.google.com/ig/api?weather='. $location); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_TIMEOUT, 10); $result = curl_exec($ch); curl_close($ch); //parse xml (thx KomunitasWeb.com for pointers) $xml = simplexml_load_string($result); $information = $xml->xpath("/xml_api_reply/weather/forecast_information"); $current = $xml->xpath("/xml_api_reply/weather/current_conditions"); $forecast_list = $xml->xpath("/xml_api_reply/weather/forecast_conditions"); ?>
= $forecast->low['data'] ?>° F - = $forecast->high['data'] ?>° F, = $forecast->condition['data'] ?>