php使用百度天氣接口示例
注意地區(qū)要轉(zhuǎn)碼的
百度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: "http://api.map.baidu.com/images/weather/day/duoyun.png",
nightPictureUrl: "http://api.map.baidu.com/images/weather/night/duoyun.png",
weather: "多云",
wind: "微風(fēng)",
temperature: "23℃"
},
{
date: "明天(周四)",
dayPictureUrl: "http://api.map.baidu.com/images/weather/day/leizhenyu.png",
nightPictureUrl: "http://api.map.baidu.com/images/weather/night/zhongyu.png",
weather: "雷陣雨轉(zhuǎn)中雨",
wind: "微風(fēng)",
temperature: "29~22℃"
},
{
date: "后天(周五)",
dayPictureUrl: "http://api.map.baidu.com/images/weather/day/yin.png",
nightPictureUrl: "http://api.map.baidu.com/images/weather/night/duoyun.png",
weather: "陰轉(zhuǎn)多云",
wind: "微風(fēng)",
temperature: "31~23℃"
},
{
date: "大后天(周六)",
dayPictureUrl: "http://api.map.baidu.com/images/weather/day/duoyun.png",
nightPictureUrl: "http://api.map.baidu.com/images/weather/night/duoyun.png",
weather: "多云",
wind: "微風(fēng)",
temperature: "31~24℃"
}
]
},
{
currentCity: "合肥市",
weather_data: [
{
date: "今天(周三)",
dayPictureUrl: "http://api.map.baidu.com/images/weather/day/duoyun.png",
nightPictureUrl: "http://api.map.baidu.com/images/weather/night/duoyun.png",
weather: "多云",
wind: "東風(fēng)3-4級",
temperature: "27℃"
},
{
date: "明天(周四)",
dayPictureUrl: "http://api.map.baidu.com/images/weather/day/duoyun.png",
nightPictureUrl: "http://api.map.baidu.com/images/weather/night/duoyun.png",
weather: "多云",
wind: "東北風(fēng)3-4級",
temperature: "35~27℃"
},
{
date: "后天(周五)",
dayPictureUrl: "http://api.map.baidu.com/images/weather/day/duoyun.png",
nightPictureUrl: "http://api.map.baidu.com/images/weather/night/duoyun.png",
weather: "多云",
wind: "南風(fēng)",
temperature: "35~27℃"
},
{
date: "大后天(周六)",
dayPictureUrl: "http://api.map.baidu.com/images/weather/day/duoyun.png",
nightPictureUrl: "http://api.map.baidu.com/images/weather/night/duoyun.png",
weather: "多云",
wind: "東風(fēng)",
temperature: "34~27℃"
}
]
}
]
}
- PHP調(diào)用API接口實現(xiàn)天氣查詢功能的示例
- PHP微信開發(fā)之查詢城市天氣
- PHP實現(xiàn)采集中國天氣網(wǎng)未來7天天氣
- php結(jié)合飛信 免費天氣預(yù)報短信
- PHP+AJAX無刷新實現(xiàn)返回天氣預(yù)報數(shù)據(jù)
- PHP 獲取指定地區(qū)的天氣實例代碼
- php實現(xiàn)的百度搜索某地天氣的小偷代碼
- PHP Ajax JavaScript Json獲取天氣信息實現(xiàn)代碼
- php采集自中央氣象臺范圍覆蓋全國的天氣預(yù)報代碼實例
- php微信開發(fā)之百度天氣預(yù)報
- PHP調(diào)用全國天氣預(yù)報數(shù)據(jù)接口查詢天氣示例
相關(guān)文章
Yii2框架操作數(shù)據(jù)庫的方法分析【以mysql為例】
這篇文章主要介紹了Yii2框架操作數(shù)據(jù)庫的方法,結(jié)合實例形式分析了Yii2框架配置、連接mysql數(shù)據(jù)庫及執(zhí)行SQL進(jìn)行增刪改查等相關(guān)操作技巧,需要的朋友可以參考下2019-05-05thinkPHP3.2.3結(jié)合Laypage實現(xiàn)的分頁功能示例
這篇文章主要介紹了thinkPHP3.2.3結(jié)合Laypage實現(xiàn)的分頁功能,結(jié)合實例形式分析了thinkPHP3.2.3結(jié)合Laypage實現(xiàn)分頁的model控制器與view視圖相關(guān)操作技巧,需要的朋友可以參考下2018-05-05php+memcache實現(xiàn)的網(wǎng)站在線人數(shù)統(tǒng)計代碼
這篇文章主要介紹了php+memcache實現(xiàn)的網(wǎng)站在線人數(shù)統(tǒng)計代碼,代碼例子簡潔實用,需要的朋友可以參考下2014-07-07- 本文章來給各位同學(xué)介紹一下關(guān)于Php CURL模擬登陸論壇并采集數(shù)據(jù)實例,如果你對利用curl模擬登錄功能有興趣可進(jìn)入?yún)⒖肌?/div> 2015-05-05
php中把美國時間轉(zhuǎn)為北京時間的自定義函數(shù)分享
這篇文章主要介紹了php中把美國時間轉(zhuǎn)為北京時間的自定義函數(shù)分享,分別提供了13小時和8小時算法版,需要的朋友可以參考下2014-07-07最新評論