百度提供天气预报查询接口API,可以根据经纬度/城市名查询天气情况,我们可以在微信公众平台开发中调用这一接口。
接口说明
根据经纬度/城市名查询天气的结果
接口示例
http://api.map.baidu.com/telematics/v3/weather?location=北京&output=json&ak=5slgyqGDENN7Sy7pw29IUvrZ
接口参数说明
String | location | true | 输入城市名或经纬度,城市名称如:北京或者131,经纬度格式为lng,lat坐标如: location=116.305145,39.982368;全国值为all,返回省会城市自治区,港澳台天气情况多城市天气预报中间"|"分隔,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 | 风力 | ||
weather_data.temperature | 温度 |
返回xml格式的数据
<CityWeatherResponse> <status>success</status> <date>2013-07-18</date> <results> <currentCity>北京市</currentCity> <weather_data> <date>周三</date> <dayPictureUrl> http://api.map.baidu.com/images/weather/day/duoyun.png </dayPictureUrl> <nightPictureUrl> http://api.map.baidu.com/images/weather/night/duoyun.png </nightPictureUrl> <weather>多云</weather> <wind>微风</wind> <temperature>23℃</temperature> <date>周四</date> <dayPictureUrl> http://api.map.baidu.com/images/weather/day/leizhenyu.png </dayPictureUrl> <nightPictureUrl> http://api.map.baidu.com/images/weather/night/zhongyu.png </nightPictureUrl> <weather>雷阵雨转中雨</weather> <wind>微风</wind> <temperature>29~22℃</temperature> <date>周五</date> <dayPictureUrl> http://api.map.baidu.com/images/weather/day/yin.png </dayPictureUrl> <nightPictureUrl> http://api.map.baidu.com/images/weather/night/duoyun.png </nightPictureUrl> <weather>阴转多云</weather> <wind>微风</wind> <temperature>31~23℃</temperature> <date>周六</date> <dayPictureUrl> http://api.map.baidu.com/images/weather/day/duoyun.png </dayPictureUrl> <nightPictureUrl> http://api.map.baidu.com/images/weather/night/duoyun.png </nightPictureUrl> <weather>多云</weather> <wind>微风</wind> <temperature>31~24℃</temperature> </weather_data> <currentCity>合肥市</currentCity> <weather_data> <date>周三</date> <dayPictureUrl> http://api.map.baidu.com/images/weather/day/duoyun.png </dayPictureUrl> <nightPictureUrl> http://api.map.baidu.com/images/weather/night/duoyun.png </nightPictureUrl> <weather>多云</weather> <wind>东风3-4级</wind> <temperature>27℃</temperature> <date>周四</date> <dayPictureUrl> http://api.map.baidu.com/images/weather/day/duoyun.png </dayPictureUrl> <nightPictureUrl> http://api.map.baidu.com/images/weather/night/duoyun.png </nightPictureUrl> <weather>多云</weather> <wind>东北风3-4级</wind> <temperature>35~27℃</temperature> <date>周五</date> <dayPictureUrl> http://api.map.baidu.com/images/weather/day/duoyun.png </dayPictureUrl> <nightPictureUrl> http://api.map.baidu.com/images/weather/night/duoyun.png </nightPictureUrl> <weather>多云</weather> <wind>南风</wind> <temperature>35~27℃</temperature> <date>周六</date> <dayPictureUrl> http://api.map.baidu.com/images/weather/day/duoyun.png </dayPictureUrl> <nightPictureUrl> http://api.map.baidu.com/images/weather/night/duoyun.png </nightPictureUrl> <weather>多云</weather> <wind>东风</wind> <temperature>34~27℃</temperature> </weather_data> </results> </CityWeatherResponse> <weather>阵雨</weather> <wind>东北风3-4级</wind> <temperature>18℃</temperature> </result> </results> </CityWeatherResponse>
返回json格式的数据
{ error: 0, status: "success", date: "2013-07-17", 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℃" } ] } ] }
相关推荐
js版得,可能显示的比较慢,显示不出来刷新下,经本人测试,可以显示出来,先去QQ查看ip,然后把ip转换为城市,最后由城市代码去查看天气
JAVA天气预报接口,使用中国天气网,气象数据开放平台的接口,比较稳定,官方说法是腾讯百度都是用他们的。。这个是根据城市ID进行查询的。
百度天气接口实现 天气预报 免费资源 可更改城市名完成近3天天气查询
基于百度的天气预报,可以添加城市和选择城市。
微信公众号开放平台,可以利用现在网络上的各种工具接口,为自己的微信公众平台增加亮点。天气查询,快递查询,手机归属地查询,身份证查询,公交查询,火车查询,健康指数查询,实时...微信天气预报接口代码 分享!
跨域请求百度天气预报跨域请求百度天气预报跨域请求百度天气预报跨域请求百度天气预报跨域请求百度天气预报跨域请求百度天气预报跨域请求百度天气预报跨域请求百度天气预报
含有jar包,直接运行没有错误,获取的天气预报绝对正确。好东西分当然高一点,绝对是你想找的。而且用的是HttpClient获取的,也可以学下HttpClient技术,有时候非常好用
* 使用百度天气预报接口获取城市天气信息案例实现 */ //获取城市天气信息 function getWeatherInfo($cityName){ if($cityName == "" || (strstr($cityName,"+"))){ return "发送城市加天气,例如北京天气"; }...
安卓基础教程开发,天气预报源代码,基本网络连接功能,使用百度提供的天气接口
Android实现天气预报功能。超级简单。实现百度地图接口就OK.
用提供的天气公共接口做的一款天气预报app源码。用到的主要技术为spinner的联动,xml文件解析,利用百度地图进行定位
qt 5写的天气预报程序,使用百度api接口,实现天气的网络查询.
练手项目,java版本android 天气预报 免费源码(新手学习)百度接口 json解析 免费下载无积分
jQuery查询城市天气预报代码基于百度地图接口,输入城市查询各地天气情况。
Android天气预报例子,利用的是百度天气接口,代码书写完全按照项目规格去写,觉得有帮助的记得鼓励一下我哦
这是一款利用百度提供的接口实现的jQuery表单输入城市查询天气预报情况代码。
使用较多的还有:新浪天气预报接口、百度天气预报接口、google天气接口、Yahoo天气接口等等。 1、查询方式 根据地名查询各城市天气情况 2.请求URL地址 http://route.showapi.com/9-2 3、接口参数说明: 一、系统级...
这是一个简单的天气预报系统,后台使用了springboot,使用了百度的接口。项目总体比较简单,可以实现简单的天气信息查询,前端部分使用了react,但是不是没有布局,只是测试。项目简单,可以锻炼一些基本的数据库...
jQuery城市天气预报查询代码基于jQuery.1.7.2.min.js制作,我在我的页面想去访问百度提供的一个服务器,百度给我们提供了很多的接口,比如说ip地址查询,比如说天气预报,比如说火车票,机票查询。
基于百度定位、百度天气接口,实现先定位、后获取当地天气的功能,且包含桌面插件的更新逻辑。