Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $place=$_GET['place'];
- $current_temperature = "nan";
- $ch = curl_init();
- $timeout = 5;
- //Set CURL options
- curl_setopt ($ch, CURLOPT_URL, "http://www.google.com/ig/api?weather=".$place."&hl=en");
- curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
- $xml_str=curl_exec($ch);
- //close CURL cause we dont need it anymore
- curl_close($ch);
- $xml = new SimpleXmlElement($xml_str);
- $current_temperature = $xml->weather->current_conditions->temp_c["data"];
- //echo $current_temperature;
- echo $current_temperature;
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement