首页 > 开发 > PHP > 正文

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

2024-05-04 21:56:55
字体:
来源:转载
供稿:网友

本文章分享一款只要三行就能取得你指定城市天气信息的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. ?>

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表