您好,登錄后才能下訂單哦!
本篇內容主要講解“php如何使用百度天氣接口”,感興趣的朋友不妨來看看。本文介紹的方法操作簡單快捷,實用性強。下面就讓小編來帶大家學習“php如何使用百度天氣接口”吧!
注意地區要轉碼的
百度ak申請地址:http://lbsyun.baidu.com/apiconsole/key
復制代碼 代碼如下:
<?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));
復制代碼 代碼如下:
{
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: "微風",
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: "雷陣雨轉中雨",
wind: "微風",
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: "陰轉多云",
wind: "微風",
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: "微風",
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: "東風3-4級",
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: "東北風3-4級",
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: "南風",
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: "東風",
temperature: "34~27℃"
}
]
}
]
}
到此,相信大家對“php如何使用百度天氣接口”有了更深的了解,不妨來實際操作一番吧!這里是億速云網站,更多相關內容可以進入相關頻道進行查詢,關注我們,繼續學習!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。