Home > Backend Development > PHP Tutorial > PHP uses Google API to obtain the current weather information code_PHP tutorial

PHP uses Google API to obtain the current weather information code_PHP tutorial

WBOY
Release: 2016-07-13 16:55:49
Original
845 people have browsed it

This article shares a php+google api implementation code that can obtain the weather information of your specified city in just three lines. Friends in need can refer to it.

The code is as follows
 代码如下 复制代码

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

?>

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

?>

http://www.bkjia.com/PHPjc/631654.htmlwww.bkjia.com
true
http: //www.bkjia.com/PHPjc/631654.html
TechArticleThis article shares a php+google api implementation code that can obtain the weather information of your specified city in just three lines. Friends in need can refer to it. The code is as follows Copy code ? $xml = si...
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 Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template