Open source free weather forecast Interface API and all country code (National Weather Bureau provided)

Source: Internet
Author: User

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
    • Http://www.weather.com.cn/data/sk/101010100.html
    • Http://www.weather.com.cn/data/cityinfo/101010100.html
    • Http://m.weather.com.cn/data/101010100.html
Number of the city

101010100 indicates the number of each city, number code get get address

    • 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.
Image interface

The data returned by using the API above contains a picture name that can be accessed through the address

    • Http://m.weather.com.cn/img/c0.gif
    • Http://m.weather.com.cn/img/b0.gif
    • Http://www.weather.com.cn/m/i/weatherpic/29x20/d0.gif
    • http://www.weather.com.cn/m2/i/icon_weather/29x20/n00.gif

This is a picture of weather phenomena 0 (clear), pictures of other weather phenomena and so on. c The picture is 20*20 pixels, B starts with 50*46 pixels, D is the anti-white icon, 29*20 pixels, N is the night anti-white icon, 29*20 pixels, note that the filename here is two digits!

Parsing data

The weather report interface provided by the National Weather Service returns JSON data, and if PHP can be converted to an array using Json_decode (), iterate through the arrays to remove the data.

Open source free weather forecast Interface API and all country code (National Weather Bureau provided)

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.