Google API php code to obtain current weather information

WBOY
Release: 2016-07-25 09:00:02
Original
1086 people have browsed it
PHP obtains the current weather information through Google API, which only requires 3 lines of code. When using it, you only need to replace ADDRESS with the city you want.

The code is as follows:

<?php
/**
 * Google API应用
 * 获取某城市的当天天气
 * by http://bbs.it-home.org
*/
$xml = simplexml_load_file('http://www.google.com/ig/api?weather=ADDRESS'); 
  $information = $xml->xpath("/xml_api_reply/weather/current_conditions/condition"); 
  echo $information[0]->attributes();
?>
Copy after login
Articles you may be interested in: An example of php weather forecast code PHP calls yahoo sina api weather forecast implementation code PHP example code for calling Google Weather API


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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!