This site part of the article translated from English documents, but limited to my English proficiency limited, there is no way to understand the statement, the end of the article is generally given the source of the translation, good English parents can refer to the original version of English. Another part of the site is gradually improving the function ...
Please look forward to! If there is a problem, you can go to the message feedback!
Weather forecast has been a basic function of the major sites, the recent small series also want to make one on the site, a little bit, in the network search for a long time, finally found the open source free weather API and all regional code (National Weather Bureau), as follows:
Weather interface provided by the National Weather
-Get Provincial code: http://www.weather.com.cn/data/list3/city.xml?level=1
-
Get city code (e.g. Anhui is): http://www.weather.com.cn/data/list3/city22.xml?level=2
-
Get area code (e.g. Anqing is 2206): http://www.weather.com.cn/data/list3/city2206.xml?level=3
Get to Anhui province Anqing Wangjiang County code is 220607
-then add the Chinese code to request url:http://m.weather.com.cn/data/101220607.html to get local weather.
Header ("Content-type:text/html;charset=utf-8"); $weather = file_get_contents ("http://www.weather.com.cn/data/sk/ 101280601.html "); Echo $weather;
The above describes the open source free weather forecast Interface API and all regions nationwide code of the National Weather bureau to provide, including aspects of the content, I hope that the PHP tutorial interested in a friend helpful.