google weather api

来源:互联网 发布:全美测评软件是什么 编辑:程序博客网 时间:2024/05/29 10:19

include("conn.php");$strsql="select * from latlon where name=’".$_GET['city']."’"; $result=mysql_db_query($mysql_database, $strsql, $conn); // u83b7u53d6u67e5u8be2u7ed3u679c,1 = name 2= latlon 3=weidu 4 = jingdu $row=mysql_fetch_row($result); mysql_data_seek($result, 0); $row=mysql_fetch_row($result); if(empty($row[1])){ $re =array( "noCity"=>"no data", "yes"=>0, ); echo ""; }else{ $nlatlon= $row[4].’,’.$row[3]; $back=$row[3]*1000000.$row[4]*1000000;$url=’http://www.google.com/ig/api?weather=,,,’.$back;$xml = simplexml_load_file($url);$re=array( "yes"=>1,"today" =>(string)($xml->weather->forecast_conditions[0]->condition['data']),"ssd"=>(string)($xml->weather->current_conditions->temp_c['data']),"sd"=>(string)($xml->weather->current_conditions->humidity['data']),"fx"=>(string)($xml->weather->current_conditions->wind_condition['data']),"icon"=>’http://www.google.com’.($xml->weather->forecast_conditions[0]->icon['data']),"week1" =>(string)($xml->weather->forecast_conditions[1]->day_of_week['data']),"week1zuidi" =>(int)((int)((string)($xml->weather->forecast_conditions[1]->low['data'])-32)/1.8+1),"week1zuigao" =>(int) ((int)((string)($xml->weather->forecast_conditions[1]->high['data'])-32)/1.8+1),"week1tianqi" =>(string)($xml->weather->forecast_conditions[1]->condition['data']),"week1icon" =>’http://www.google.com’.($xml->weather->forecast_conditions[1]->icon['data']),"week2" =>(string)($xml->weather->forecast_conditions[2]->day_of_week['data']),"week2zuidi" =>(int) ((int)((string)($xml->weather->forecast_conditions[2]->low['data'])-32)/1.8+1),"week2zuigao" =>(int) ((int)((string)($xml->weather->forecast_conditions[2]->high['data'])-32)/1.8+1),"week2tianqi" =>(string)($xml->weather->forecast_conditions[2]->condition['data']),"week2icon" =>’http://www.google.com’.($xml->weather->forecast_conditions[2]->icon['data']),"week3" =>(string)($xml->weather->forecast_conditions[3]->day_of_week['data']),"week3zuidi" =>(int) ((int)((string)($xml->weather->forecast_conditions[3]->low['data'])-32)/1.8+1),"week3zuigao" =>(int) ((int)((string)($xml->weather->forecast_conditions[3]->high['data'])-32)/1.8+1),"week3tianqi" =>(string)($xml->weather->forecast_conditions[3]->condition['data']),"week3icon" =>’http://www.google.com’.($xml->weather->forecast_conditions[3]->icon['data']),"nlatlon" =>$nlatlon,"googleurl"=>$url,);}echo json_encode($re); mysql_free_result($result);mysql_close($conn);

原创粉丝点击