Example of using Baidu weather interface in PHP_PHP tutorial

WBOY
Release: 2016-07-13 10:32:03
Original
764 people have browsed it

Note that regions require transcoding
Baidu ak application address: http://lbsyun.baidu.com/apiconsole/key

Copy code The code is as follows:

$city="Jiaxing";
$content = file_get_contents("http://api.map.baidu.com/telematics/v3/weather?location=%E5%98%89%E5%85% B4&output=json&ak=5slgyqGDENN7Sy7pw29IUvrZ");
print_r(json_decode($content));

Copy code The code is as follows:

{
error: 0,
status: "success",
date: "2014-04-18",
results: [
currentCity : "Jiaxing",
weather_data: [
{
date: "Today (Wednesday)",
dayPictureUrl: "http://api.map. baidu.com/images/weather/day /duoyun.png",
nightPictureUrl: "http://api.map.baidu.com/images/weather/night/duoyun.png",
weather: "Cloudy",
Wind: " Breeze",
temperature: "23℃"
},
date: "Tomorrow (Thursday)",
dayPictureUrl: "http://api.map.baidu. com/images/weather/day/leizhenyu.png",
nightPictureUrl: "http://api.map.baidu.com/images/weather/night/zhongyu.png",
weather: "Thunderstorms turning Moderate rain",
wind: "Breeze",
temperature: "29~22℃"
},
{
             date: "The day after tomorrow (Friday)",
              dayPictureUrl : "http://api.map.baidu.com/images/weather/day/yin.png",
                                  nightPictureUrl: "http://api.map.baidu.com/images/weather/night/duoyun .png",
weather: "Chanting to cloudy",
wind: "Breeze",
temperature: "31~23℃"
                                                                                                                   The day after tomorrow (Saturday)",
dayPictureUrl: "http://api.map.baidu.com/images/weather/day/duoyun.png",
nightPictureUrl: "http://api.map. baidu.com/images/weather/night/duoyun.png",
         weather: "Cloudy",
                                                                                                                                                                                                                                         🎜>                             
                                                                                                                                                                                                   🎜>           date: "Today (Wednesday)",
              dayPictureUrl: "http://api.map.baidu.com/images/weather/day/duoyun.png",
                                nightPictureUrl: "http://api.map.baidu.com/images/weather/night/duoyun. png",
weather: "Cloudy",
wind: "Dongfeng level 3-4",
temperature: "27℃"
},
{
date: "Tomorrow (Thursday)",
dayPictureUrl: "http://api.map.baidu.com/images/weather/day/duoyun.png",
nightPictureUrl: "http://api.map.baidu .com/images/weather/night/duoyun.png",
weather: "Cloudy",
wind: "Northeast wind level 3-4",
temperature: "35~27℃"
            },
                                                                                                                                              weather/day/duoyun.png",
           nightPictureUrl: "http://api.map.baidu.com/images/weather/night/duoyun.png",
         weather: "Cloudy",
                                                                                                                             ,
temperature: "35~27℃"
        },
                                                                                                                                                           "http://api.map.baidu.com/images/ Weather/day/duoyun.png ",
nightpicTureurl:" http://api.map.baidu.com/images/weather/night/duoyun.png ",
" WEATHER: "Duoyun",
wind: "east wind",
temperature: "34~27℃"
}
]
}
]
}

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/759334.htmlTechArticlePlease note the Baidu ak application address for transcoding in regions: http://lbsyun.baidu.com/apiconsole/key Copy the code as follows: ?php $city="Jiaxing"; $content = file_get_contents("http://api.map....
Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template