php使用百度天氣接口示例
更新時間:2014年04月22日 09:45:54 作者:
這篇文章主要介紹了百度天氣接口使用示例,需要的朋友可以參考下
注意地區(qū)要轉碼的
百度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: "微風",
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: "雷陣雨轉中雨",
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: "陰轉多云",
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℃"
}
]
}
]
}
相關文章
thinkPHP3.2.3結合Laypage實現的分頁功能示例
這篇文章主要介紹了thinkPHP3.2.3結合Laypage實現的分頁功能,結合實例形式分析了thinkPHP3.2.3結合Laypage實現分頁的model控制器與view視圖相關操作技巧,需要的朋友可以參考下2018-05-05php+memcache實現的網站在線人數統(tǒng)計代碼
這篇文章主要介紹了php+memcache實現的網站在線人數統(tǒng)計代碼,代碼例子簡潔實用,需要的朋友可以參考下2014-07-07