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 |