Home > php教程 > php手册 > body text

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

WBOY
Release: 2016-06-02 09:15:01
Original
1051 people have browsed it
本文章分享一款只要三行就能取得你指定城市天气信息的php+google api实现代码,有需要的朋友可以参考一下。
 代码如下 复制代码


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

?>



source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!