Weather Forecast API Development

Source: Internet
Author: User

Weather forecast API Development One, search for the article

Recently want to follow the video practice using the API to develop a weather system, on the Internet to find the API can be used, the results of many have been invalidated ...

1. Baidu car Networking weather forecast API (failed)

The first is to find a video of the Baidu developer platform –lbs–-weather API, the results found that the service has been discontinued in December 2015

2. China Weather Net API (failed)

No way, since Baidu does not bird me, can only continue to look for anything else. Is Baidu a business?

Baidu has a "weather API" (^-^), found that there is an old API interface, we are using:

Weather Report interface provided by the National Weather Bureau, listen to the domineering:

    • Http://www.weather.com.cn/data/sk/101010100.html

Returns the following content

    • Http://www.weather.com.cn/data/cityinfo/101010100.html

Returns the following content

    • Http://m.weather.com.cn/data/101010100.html (return 7 days weather conditions)

The third is said to return the information is more comprehensive, but looked at the next point after the page, or forget

The first and second look quite normal, that is, the information returned is less, pinch the nose can also be used ...

Wait, it's like there's something wrong. Beijing's temperature today is: -2℃? I looked down at the bottom right corner of the calendar, uh, May 20, Good day-dog abuse days. 886

3. Sina Weather API (uncertain)

Continue to search, and found a Sina weather API,

Http://php.weather.sina.com.cn/xml.php?city=%B1%B1%BE%A9&password=DJOYnieT8234jlsK&day=0

Click on the below, as

The frame of the part has temperature information, probably can be engaged in

Try the other cities before you start. So I changed the URL to this:

http://php.weather.sina.com.cn/xml.php?city= Hefei &password=djoyniet8234jlsk&day=0

What ghost, is the Chinese character to transcode? So I turned the other yard.

It turns out that I think more, now it seems that the password part of the back, I have to make one, but I do not know where to engage, forget it, keep looking

This time in the blog park to find out whether in recent months in the post of the weather forecast API, the result has really found a:

4. and wind Weather API (OK)

Various Interface API documentation ... Well, say it in detail. Suddenly burst into tears

Sign up and get up.

Finally there is a message back, good detail, decided to use this.

Second, the Analytic chapter

I thought I could have found the API, and then it's not just a 2 down the handle.

The result has not yet begun to be blocked again.

This is what the ghost, how the name part of the JSON can also have spaces.

I tried the echo $data in this notation. Heweather data Service 3.0[0].aqi.city; As expected, I thought it was too simple, how could this be obtained

Continue Baidu. See someone write Echo $data [' Heweather Data Service 3.0 '][0].aqi.city; I'll try, but it's still not responding.

Cool, this wonderful format, it must be someone else's string splicing out, since the return is a JSON word, is it possible to first treat it as a string first:

Well finally with Json_decode turned into a multi-dimensional array of the situation, after the turn and then use the json_encode myself to turn into JSON format, output to the front. The rest is put in the right place after the front-end value.

Weather Forecast API Development

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.