百度天⽓API接⼝接⼝说明
根据经纬度/城市名查询天⽓的结果。
接⼝参数说明
参数类
型参数名称
是否必
具体描述
String ak true开发者密钥
String sn false若⽤户所⽤ak的校验⽅式为sn校验时该参数必须。
String location true 输⼊城市名或经纬度,城市名称如:北京,经纬度格式为lng,lat坐标如:
location=116.305145,39.982368;城市天⽓预报中间"|"分隔,location=116.305145,39.982368| 122.305145,36.982368|….
String output false输出的数据格式,默认为xml格式,当output设置为’json’时,输出的为json格式的数据;
String coord_type false 请求参数坐标类型,默认为gcj02经纬度坐标。允许的值为bd09ll、bd09mc、gcj02、wgs84。bd09ll表⽰百度经纬度坐标,bd09mc表⽰百度墨卡托坐标,gcj02表⽰经过国测局加密的坐标。wgs84表⽰gps获取的坐标。
返回结果
参数名称含义说明currentCity当前城市返回城市名
status返回结果状态信息
date当前时间年-⽉-⽇
results天⽓预报信息⽩天可返回近期3天的天⽓情况(今天、明天、后天)、晚上可返回近期4天的天⽓情况(今天、明天、后天、⼤后天)
results.currentCity当前城市
results.weather_data weather_data.date天⽓预报时间
weather_data.dayPictureUrl⽩天的天⽓预报图⽚url
weather_data.nightPictureUrl晚上的天⽓预报图⽚url
weather_data.weather天⽓状况
所有天⽓情况(”|”分隔符):晴|多云|阴|阵⾬|雷阵⾬|雷阵
⾬伴有冰雹|⾬夹雪|⼩⾬|中⾬|⼤⾬|暴⾬|⼤暴⾬|特⼤暴⾬|
阵雪|⼩雪|中雪|⼤雪|暴雪|雾|冻⾬|沙尘暴|⼩⾬转中⾬|中⾬
转⼤⾬|⼤⾬转暴⾬|暴⾬转⼤暴⾬|⼤暴⾬转特⼤暴⾬|⼩雪
转中雪|中雪转⼤雪|⼤雪转暴雪|浮尘|扬沙|强沙尘暴|霾weather_data.wind风⼒
perature温度
返回xml格式的数据
<?xml version="1.0" encoding="utf-8" ?>
<CityWeatherResponse>
<status>success</status>
<date>2014-05-03</date>
<results>
<currentCity>北京</currentCity>
<weather_data>
<date>周六(今天, 实时:22℃)</date>
<dayPictureUrl>api.map.baidu/images/weather/day/leizhenyu.png</dayPictureUrl>                <nightPictureUrl>api.map.baidu/images/weather/night/duoyun.png</nightPictureUrl>                <weather>雷阵⾬转多云</weather>
<wind>北风5-6级</wind>
<temperature>24 ~ 11℃</temperature>
<date>周⽇</date>
<dayPictureUrl>api.map.baidu/images/weather/day/duoyun.png</dayPictureUrl>
<nightPictureUrl>api.map.baidu/images/weather/night/qing.png</nightPictureUrl>                <weather>多云转晴</weather>
<wind>北风4-5级</wind>
百度api接口<temperature>19 ~ 8℃</temperature>
<date>周⼀</date>
<dayPictureUrl>api.map.baidu/images/weather/day/qing.png</dayPictureUrl>
<nightPictureUrl>api.map.baidu/images/weather/night/qing.png</nightPictureUrl>
<weather>晴</weather>
<wind>微风</wind>
<temperature>21 ~ 9℃</temperature>
<date>周⼆</date>
<dayPictureUrl>api.map.baidu/images/weather/day/duoyun.png</dayPictureUrl>                <nightPictureUrl>api.map.baidu/images/weather/night/qing.png</nightPictureUrl>                <weather>多云转晴</weather>
<wind>微风</wind>
<temperature>21 ~ 10℃</temperature>
</weather_data>
</results>
</CityWeatherResponse>
返回json格式的数据
{
"error": 0,
"status": "success",
"date": "2014-05-03",
"results": [
{
"currentCity": "北京",
"weather_data": [
{
"date": "周六(今天, 实时:22℃)",
"dayPictureUrl": "api.map.baidu/images/weather/day/leizhenyu.png",
"nightPictureUrl": "api.map.baidu/images/weather/night/duoyun.png",
"weather": "雷阵⾬转多云",
"wind": "北风5-6级",
"temperature": "24 ~ 11℃"
},
{
"date": "周⽇",
"dayPictureUrl": "api.map.baidu/images/weather/day/duoyun.png",
"nightPictureUrl": "api.map.baidu/images/weather/night/qing.png",
"weather": "多云转晴",
"wind": "北风4-5级",
"temperature": "19 ~ 8℃"
},
{
"date": "周⼀",
"dayPictureUrl": "api.map.baidu/images/weather/day/qing.png",
"nightPictureUrl": "api.map.baidu/images/weather/night/qing.png",
"weather": "晴",
"wind": "微风",
"temperature": "21 ~ 9℃"
},
{
"date": "周⼆",
"dayPictureUrl": "api.map.baidu/images/weather/day/duoyun.png",
"nightPictureUrl": "api.map.baidu/images/weather/night/qing.png",
"weather": "多云转晴",
"wind": "微风",
"temperature": "21 ~ 10℃"
}
]
}
]
}