google weather api

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);

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值