您好,登錄后才能下訂單哦!
本篇內(nèi)容主要講解“php如何使用百度天氣接口”,感興趣的朋友不妨來看看。本文介紹的方法操作簡(jiǎn)單快捷,實(shí)用性強(qiáng)。下面就讓小編來帶大家學(xué)習(xí)“php如何使用百度天氣接口”吧!
注意地區(qū)要轉(zhuǎn)碼的
百度ak申請(qǐng)地址:http://lbsyun.baidu.com/apiconsole/key
復(fù)制代碼 代碼如下:
<?php
$city="嘉興";
$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));
復(fù)制代碼 代碼如下:
{
error: 0,
status: "success",
date: "2014-04-18",
results: [
{
currentCity: "嘉興",
weather_data: [
{
date: "今天(周三)",
dayPictureUrl: "https://cache.yisu.com/upload/information/20201209/266/42918.png",
nightPictureUrl: "https://cache.yisu.com/upload/information/20201209/266/42919.png",
weather: "多云",
wind: "微風(fēng)",
temperature: "23℃"
},
{
date: "明天(周四)",
dayPictureUrl: "https://cache.yisu.com/upload/information/20201209/266/42920.png",
nightPictureUrl: "https://cache.yisu.com/upload/information/20201209/266/42921.png",
weather: "雷陣雨轉(zhuǎn)中雨",
wind: "微風(fēng)",
temperature: "29~22℃"
},
{
date: "后天(周五)",
dayPictureUrl: "https://cache.yisu.com/upload/information/20201209/266/42922.png",
nightPictureUrl: "https://cache.yisu.com/upload/information/20201209/266/42919.png",
weather: "陰轉(zhuǎn)多云",
wind: "微風(fēng)",
temperature: "31~23℃"
},
{
date: "大后天(周六)",
dayPictureUrl: "https://cache.yisu.com/upload/information/20201209/266/42918.png",
nightPictureUrl: "https://cache.yisu.com/upload/information/20201209/266/42919.png",
weather: "多云",
wind: "微風(fēng)",
temperature: "31~24℃"
}
]
},
{
currentCity: "合肥市",
weather_data: [
{
date: "今天(周三)",
dayPictureUrl: "https://cache.yisu.com/upload/information/20201209/266/42918.png",
nightPictureUrl: "https://cache.yisu.com/upload/information/20201209/266/42919.png",
weather: "多云",
wind: "東風(fēng)3-4級(jí)",
temperature: "27℃"
},
{
date: "明天(周四)",
dayPictureUrl: "https://cache.yisu.com/upload/information/20201209/266/42918.png",
nightPictureUrl: "https://cache.yisu.com/upload/information/20201209/266/42919.png",
weather: "多云",
wind: "東北風(fēng)3-4級(jí)",
temperature: "35~27℃"
},
{
date: "后天(周五)",
dayPictureUrl: "https://cache.yisu.com/upload/information/20201209/266/42918.png",
nightPictureUrl: "https://cache.yisu.com/upload/information/20201209/266/42919.png",
weather: "多云",
wind: "南風(fēng)",
temperature: "35~27℃"
},
{
date: "大后天(周六)",
dayPictureUrl: "https://cache.yisu.com/upload/information/20201209/266/42918.png",
nightPictureUrl: "https://cache.yisu.com/upload/information/20201209/266/42919.png",
weather: "多云",
wind: "東風(fēng)",
temperature: "34~27℃"
}
]
}
]
}
到此,相信大家對(duì)“php如何使用百度天氣接口”有了更深的了解,不妨來實(shí)際操作一番吧!這里是億速云網(wǎng)站,更多相關(guān)內(nèi)容可以進(jìn)入相關(guān)頻道進(jìn)行查詢,關(guān)注我們,繼續(xù)學(xué)習(xí)!
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。