php使用百度天氣接口示例
更新時間:2014年04月22日 09:45:54 作者:
這篇文章主要介紹了百度天氣接口使用示例,需要的朋友可以參考下
注意地區(qū)要轉(zhuǎn)碼的
百度ak申請地址: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: "http://api.map.baidu.com/images/weather/day/duoyun.png",
nightPictureUrl: "http://api.map.baidu.com/images/weather/night/duoyun.png",
weather: "多云",
wind: "微風",
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: "微風",
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: "微風",
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: "微風",
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: "東風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: "東北風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: "南風",
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: "東風",
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)文章
PHP實現(xiàn)的簡單留言板功能示例【基于thinkPHP框架】
這篇文章主要介紹了PHP實現(xiàn)的簡單留言板功能,結(jié)合實例形式分析了基于thinkPHP框架實現(xiàn)的留言板相關(guān)配置、數(shù)據(jù)庫操作、sql語句等實現(xiàn)技巧與操作注意事項,需要的朋友可以參考下2018-12-12
Ecshop 后臺添加新功能欄目及管理權(quán)限設(shè)置教程
這篇文章主要介紹了Ecshop 后臺添加新功能欄目及管理權(quán)限設(shè)置教程,需要的朋友可以參考下2017-11-11
yii實現(xiàn)model添加默認值的方法(2種方法)
這篇文章主要介紹了yii實現(xiàn)model添加默認值的方法,結(jié)合實例分析了在rules()方法及在beforeSave()方法中設(shè)定兩種實現(xiàn)技巧,需要的朋友可以參考下2016-01-01

