百度天气预报接口介绍

百度提供天气预报查询接口API,可以根据经纬度/城市名查询天气情况,我们可以在微信公众平台开发中调用这一接口。

接口说明

根据经纬度/城市名查询天气的结果

接口示例

http://api.map.baidu.com/telematics/v3/weather?location=北京&output=json&ak=6tYzTvGZSOpYB5Oc2YGGOKt8

百度ak申请地址:http://lbsyun.baidu.com/apiconsole/key

接口参数说明

参数类型 参数名称 是否必须 具体描述
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获取的坐标。
String ak true 访问应用(ak) 需要在百度lbs开放平台申请

返回结果

参数名称 含义 说明
currentCity 当前城市 返回城市名
status 返回结果状态信息  
date 当前时间 年-月-日
results 天气预报信息 白天可返回近期3天的天气情况(今天、明天、后天)、晚上可返回近期4天的天气情况(今天、明天、后天、大后天)
results.currentCity 当前城市  
results.weather_data 天气预报时间  
weather_data.dayPictureUrl 白天的天气预报图片url  
weather_data.nightPictureUrl 晚上的天气预报图片url  
weather_data.weather 天气状况 所有天气情况(”|”分隔符)
weather_data.wind 风力  
weather_data.temperature 温度  

返回JSON格式的数据

{
    "error": 0,
    "status": "success",
    "date": "2014-09-17",
    "results": [
        {
            "currentCity": "北京",
            "pm25": "153",
            "index": [
                {
                    "title": "穿衣",
                    "zs": "较舒适",
                    "tipt": "穿衣指数",
                    "des": "建议着薄外套或牛仔衫裤等服装。年老体弱者宜着夹克衫、薄毛衣等。昼夜温差较大,注意适当增减衣服。"
                },
                {
                    "title": "洗车",
                    "zs": "较适宜",
                    "tipt": "洗车指数",
                    "des": "较适宜洗车,未来一天无雨,风力较小,擦洗一新的汽车至少能保持一天。"
                },
                {
                    "title": "旅游",
                    "zs": "适宜",
                    "tipt": "旅游指数",
                    "des": "天气较好,但丝毫不会影响您出行的心情。温度适宜又有微风相伴,适宜旅游。"
                },
                {
                    "title": "感冒",
                    "zs": "少发",
                    "tipt": "感冒指数",
                    "des": "各项气象条件适宜,无明显降温过程,发生感冒机率较低。"
                },
                {
                    "title": "运动",
                    "zs": "较适宜",
                    "tipt": "运动指数",
                    "des": "天气较好,但考虑气温较低,推荐您进行室内运动,若户外适当增减衣物并注意防晒。"
                },
                {
                    "title": "紫外线强度",
                    "zs": "弱",
                    "tipt": "紫外线强度指数",
                    "des": "紫外线强度较弱,建议出门前涂擦SPF在12-15之间、PA+的防晒护肤品。"
                }
            ],
            "weather_data": [
                {
                    "date": "周三 09月17日 (实时:21℃)",
                    "dayPictureUrl": "http://api.map.baidu.com/images/weather/day/duoyun.png",
                    "nightPictureUrl": "http://api.map.baidu.com/images/weather/night/qing.png",
                    "weather": "多云转晴",
                    "wind": "微风",
                    "temperature": "23 ~ 12℃"
                },
                {
                    "date": "周四",
                    "dayPictureUrl": "http://api.map.baidu.com/images/weather/day/qing.png",
                    "nightPictureUrl": "http://api.map.baidu.com/images/weather/night/duoyun.png",
                    "weather": "晴转多云",
                    "wind": "微风",
                    "temperature": "25 ~ 15℃"
                },
                {
                    "date": "周五",
                    "dayPictureUrl": "http://api.map.baidu.com/images/weather/day/yin.png",
                    "nightPictureUrl": "http://api.map.baidu.com/images/weather/night/yin.png",
                    "weather": "阴",
                    "wind": "微风",
                    "temperature": "23 ~ 15℃"
                },
                {
                    "date": "周六",
                    "dayPictureUrl": "http://api.map.baidu.com/images/weather/day/qing.png",
                    "nightPictureUrl": "http://api.map.baidu.com/images/weather/night/qing.png",
                    "weather": "晴",
                    "wind": "微风",
                    "temperature": "29 ~ 16℃"
                }
            ]
        }
    ]
}

返回XML格式的数据

[xml]  预览 复制
  1. <?xml version="1.0" encoding="utf-8"?>  
  2.   
  3. <CityWeatherResponse>   
  4.  <error>0</error>   
  5.  <status>success</status>   
  6.  <date>2014-09-17</date>   
  7.  <results>   
  8.  <currentCity>北京</currentCity>   
  9.  <weather_data>   
  10.  <date>周三 09月17日 (实时:21℃)</date>   
  11.  <dayPictureUrl>http://api.map.baidu.com/images/weather/day/duoyun.png</dayPictureUrl>   
  12.  <nightPictureUrl>http://api.map.baidu.com/images/weather/night/qing.png</nightPictureUrl>   
  13.  <weather>多云转晴</weather>   
  14.  <wind>微风</wind>   
  15.  <temperature>23 ~ 12℃</temperature>   
  16.  <date>周四</date>   
  17.  <dayPictureUrl>http://api.map.baidu.com/images/weather/day/qing.png</dayPictureUrl>   
  18.  <nightPictureUrl>http://api.map.baidu.com/images/weather/night/duoyun.png</nightPictureUrl>   
  19.  <weather>晴转多云</weather>   
  20.  <wind>微风</wind>   
  21.  <temperature>25 ~ 15℃</temperature>   
  22.  <date>周五</date>   
  23.  <dayPictureUrl>http://api.map.baidu.com/images/weather/day/yin.png</dayPictureUrl>   
  24.  <nightPictureUrl>http://api.map.baidu.com/images/weather/night/yin.png</nightPictureUrl>   
  25.  <weather></weather>   
  26.  <wind>微风</wind>   
  27.  <temperature>23 ~ 15℃</temperature>   
  28.  <date>周六</date>   
  29.  <dayPictureUrl>http://api.map.baidu.com/images/weather/day/qing.png</dayPictureUrl>   
  30.  <nightPictureUrl>http://api.map.baidu.com/images/weather/night/qing.png</nightPictureUrl>   
  31.  <weather></weather>   
  32.  <wind>微风</wind>   
  33.  <temperature>29 ~ 16℃</temperature>   
  34.  </weather_data>   
  35.  <index>   
  36.  <title>穿衣</title>   
  37.  <zs>较舒适</zs>   
  38.  <tipt>穿衣指数</tipt>   
  39.  <des>建议着薄外套或牛仔衫裤等服装。年老体弱者宜着夹克衫、薄毛衣等。昼夜温差较大,注意适当增减衣服。</des>   
  40.  <title>洗车</title>   
  41.  <zs>较适宜</zs>   
  42.  <tipt>洗车指数</tipt>   
  43.  <des>较适宜洗车,未来一天无雨,风力较小,擦洗一新的汽车至少能保持一天。</des>   
  44.  <title>旅游</title>   
  45.  <zs>适宜</zs>   
  46.  <tipt>旅游指数</tipt>   
  47.  <des>天气较好,但丝毫不会影响您出行的心情。温度适宜又有微风相伴,适宜旅游。</des>   
  48.  <title>感冒</title>   
  49.  <zs>少发</zs>   
  50.  <tipt>感冒指数</tipt>   
  51.  <des>各项气象条件适宜,无明显降温过程,发生感冒机率较低。</des>   
  52.  <title>运动</title>   
  53.  <zs>较适宜</zs>   
  54.  <tipt>运动指数</tipt>   
  55.  <des>天气较好,但考虑气温较低,推荐您进行室内运动,若户外适当增减衣物并注意防晒。</des>   
  56.  <title>紫外线强度</title>   
  57.  <zs></zs>   
  58.  <tipt>紫外线强度指数</tipt>   
  59.  <des>紫外线强度较弱,建议出门前涂擦SPF在12-15之间、PA+的防晒护肤品。</des>   
  60.  </index>   
  61.  <pm25>153</pm25>   
  62.  </results>   
  63. </CityWeatherResponse>  
  • 1
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 4
    评论
提供的源码资源涵盖了Java应用等多个领域,每个领域都包含了丰富的实例和项目。这些源码都是基于各自平台的最新技术和标准编写,确保了在对应环境下能够无缝运行。同时,源码中配备了详细的注释和文档,帮助用户快速理解代码结构和实现逻辑。 适用人群: 适合毕业设计、课程设计作业。这些源码资源特别适合大学生群体。无论你是计算机相关专业的学生,还是对其他领域编程感兴趣的学生,这些资源都能为你提供宝贵的学习和实践机会。通过学习和运行这些源码,你可以掌握各平台开发的基础知识,提升编程能力和项目实战经验。 使用场景及目标: 在学习阶段,你可以利用这些源码资源进行课程实践、课外项目或毕业设计。通过分析和运行源码,你将深入了解各平台开发的技术细节和最佳实践,逐步培养起自己的项目开发和问题解决能力。此外,在求职或创业过程中,具备跨平台开发能力的大学生将更具竞争力。 其他说明: 为了确保源码资源的可运行性和易用性,特别注意了以下几点:首先,每份源码都提供了详细的运行环境和依赖说明,确保用户能够轻松搭建起开发环境;其次,源码中的注释和文档都非常完善,方便用户快速上手和理解代码;最后,我会定期更新这些源码资源,以适应各平台技术的最新发展和市场需求。 所有源码均经过严格测试,可以直接运行,可以放心下载使用。有任何使用问题欢迎随时与博主沟通,第一时间进行解答!

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值