加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

php 利用Google API 获取当前天气信息代码

发布时间:2020-12-13 20:32:37 所属栏目:PHP教程 来源:网络整理
导读:本文章分享一款只要三行就能取得你指定城市天气信息的php+google api实现代码,代码如下: ? $xml =simplexml_load_file( http://www.google.com/ig/api?weather=长沙 ); $information = $xml -xpath( /xml_api_reply/weather/current_conditions/condition

本文章分享一款只要三行就能取得你指定城市天气信息的php+google api实现代码,代码如下:

  1. <? 
  2. $xml = simplexml_load_file('http://www.google.com/ig/api?weather=长沙');  
  3. $information = $xml->xpath("/xml_api_reply/weather/current_conditions/condition");  
  4. echo $information[0]->attributes(); 
  5. ?>

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读