php使用百度天氣接口示例
注意地區(qū)要轉(zhuǎn)碼的
百度ak申請(qǐng)地址: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級(jí)",
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級(jí)",
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接口實(shí)現(xiàn)天氣查詢功能的示例
- PHP微信開發(fā)之查詢城市天氣
- PHP實(shí)現(xiàn)采集中國天氣網(wǎng)未來7天天氣
- php結(jié)合飛信 免費(fèi)天氣預(yù)報(bào)短信
- PHP+AJAX無刷新實(shí)現(xiàn)返回天氣預(yù)報(bào)數(shù)據(jù)
- PHP 獲取指定地區(qū)的天氣實(shí)例代碼
- php實(shí)現(xiàn)的百度搜索某地天氣的小偷代碼
- PHP Ajax JavaScript Json獲取天氣信息實(shí)現(xiàn)代碼
- php采集自中央氣象臺(tái)范圍覆蓋全國的天氣預(yù)報(bào)代碼實(shí)例
- php微信開發(fā)之百度天氣預(yù)報(bào)
- PHP調(diào)用全國天氣預(yù)報(bào)數(shù)據(jù)接口查詢天氣示例
相關(guān)文章
Yii2框架操作數(shù)據(jù)庫的方法分析【以mysql為例】
這篇文章主要介紹了Yii2框架操作數(shù)據(jù)庫的方法,結(jié)合實(shí)例形式分析了Yii2框架配置、連接mysql數(shù)據(jù)庫及執(zhí)行SQL進(jìn)行增刪改查等相關(guān)操作技巧,需要的朋友可以參考下2019-05-05thinkPHP3.2.3結(jié)合Laypage實(shí)現(xiàn)的分頁功能示例
這篇文章主要介紹了thinkPHP3.2.3結(jié)合Laypage實(shí)現(xiàn)的分頁功能,結(jié)合實(shí)例形式分析了thinkPHP3.2.3結(jié)合Laypage實(shí)現(xiàn)分頁的model控制器與view視圖相關(guān)操作技巧,需要的朋友可以參考下2018-05-05php+memcache實(shí)現(xiàn)的網(wǎng)站在線人數(shù)統(tǒng)計(jì)代碼
這篇文章主要介紹了php+memcache實(shí)現(xiàn)的網(wǎng)站在線人數(shù)統(tǒng)計(jì)代碼,代碼例子簡(jiǎn)潔實(shí)用,需要的朋友可以參考下2014-07-07PHP如何通過AJAX方式實(shí)現(xiàn)登錄功能
PHP是一門很好的語言,可以很方便的開發(fā)web應(yīng)用程序,下面介紹一下Ajax+PHP+MySQL登陸示例,感興趣的小伙伴們可以參考一下2015-11-11- 本文章來給各位同學(xué)介紹一下關(guān)于Php CURL模擬登陸論壇并采集數(shù)據(jù)實(shí)例,如果你對(duì)利用curl模擬登錄功能有興趣可進(jìn)入?yún)⒖肌?/div> 2015-05-05
php中把美國時(shí)間轉(zhuǎn)為北京時(shí)間的自定義函數(shù)分享
這篇文章主要介紹了php中把美國時(shí)間轉(zhuǎn)為北京時(shí)間的自定義函數(shù)分享,分別提供了13小時(shí)和8小時(shí)算法版,需要的朋友可以參考下2014-07-07最新評(píng)論