Open-source free weather forecast API and code provided by the National Meteorological Administration of all regions

Source: Internet
Author: User
: This article mainly introduces the open-source free weather forecast API and the code provided by the National Meteorological Administration of all regions of the country. if you are interested in PHP tutorials, please refer to it. Some articles on this site are translated from English documents, but my English level is limited. please forgive me if you have any statements. the Source of the translations is usually provided at the end of this article, for more information, see the original English version. In addition, some functions of this site are gradually being improved ......
Coming soon! If you have any questions, you can move to the feedback page!
The weather forecast has always been a basic function of major websites. Recently, I want to get a weather report from my website. I 've been searching for it on the Internet for a long time, finally, we found the open-source free weather forecast API and the code for all regions of the country (provided by the National Meteorological Administration). The details are as follows:
Weather forecast interface provided by the National Meteorological Administration
-Get provincial code: http://www.weather.com.cn/data/list3/city.xml? Level = 1
-
Get city code (for example, Anhui is 22): http://www.weather.com.cn/data/list3/city22.xml? Level = 2
-
Get the region code (for example, Anqing is 2206): http://www.weather.com.cn/data/list3/city2206.xml? Level = 3
The code obtained from Wangjiang county, Anqing city, Anhui province is 220607

-Then add the Chinese code request URL: http://m.weather.com.cn/data/101220607.html to get the 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 introduces the open-source free weather forecast API and the code provided by the National Meteorological Administration of all regions of the country, including the content, hope to be helpful to friends who are interested in PHP tutorials.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.