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)文章
多個(gè)Laravel項(xiàng)目如何共用migrations詳解
這篇文章主要給大家介紹了關(guān)于多個(gè)Laravel項(xiàng)目如何共用migrations的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面來一起看看吧2018-09-09
PHP實(shí)現(xiàn)的簡單留言板功能示例【基于thinkPHP框架】
這篇文章主要介紹了PHP實(shí)現(xiàn)的簡單留言板功能,結(jié)合實(shí)例形式分析了基于thinkPHP框架實(shí)現(xiàn)的留言板相關(guān)配置、數(shù)據(jù)庫操作、sql語句等實(shí)現(xiàn)技巧與操作注意事項(xiàng),需要的朋友可以參考下2018-12-12
Ecshop 后臺(tái)添加新功能欄目及管理權(quán)限設(shè)置教程
這篇文章主要介紹了Ecshop 后臺(tái)添加新功能欄目及管理權(quán)限設(shè)置教程,需要的朋友可以參考下2017-11-11
yii實(shí)現(xiàn)model添加默認(rèn)值的方法(2種方法)
這篇文章主要介紹了yii實(shí)現(xiàn)model添加默認(rèn)值的方法,結(jié)合實(shí)例分析了在rules()方法及在beforeSave()方法中設(shè)定兩種實(shí)現(xiàn)技巧,需要的朋友可以參考下2016-01-01

