博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
天气查询接口文档
阅读量:4311 次
发布时间:2019-06-06

本文共 1758 字,大约阅读时间需要 5 分钟。

 

天气查询接口演示代码:

using System;

using System.Text;

using System.Net;

namespace tianqi {

    class Program

    {

        static void Main(string[] args)

        {

            string key = "*********************";//申请的key值

            string cityname = "北京";//输入想要查询的城市名

            string url = "=" +cityname + "&key=" + key;

            WebClient wc = new WebClient();

            wc.Encoding = Encoding.UTF8;

            string str = wc.DownloadString(url);

            Console.WriteLine(str);

            Console.ReadKey();

        }

    }

}

天气查询接口返回示例代码:

天气查询接口:

支持格式: json

http请求方式:GET POST

返回示例: {

   "resultcode": "200",

    "reason": "查询成功!",

    "result": {

        "sk": { /*当前实况天气*/

            "temp": "21", /*当前温度*/

            "wind_direction": "西风", /*当前风向*/

            "wind_strength": "2级", /*当前风力*/

              "humidity": "4%", /*当前湿度*/

            "time": "14:25" /*更新时间*/

        },

        "today": {

            "city": "天津",

            "date_y": "2014年03月21日",

            "week": "星期五",

            "temperature": "8℃~20℃", /*今日温度*/

            "weather": "晴转霾", /*今日天气*/

            "weather_id": { /*天气唯一标识*/

                "fa": "00", /*天气标识00:晴*/

                "fb": "53" /*天气标识53:霾 如果fa不等于fb,说明是组合天气*/

            },

            "wind": "西南风微风",

            "dressing_index": "较冷", /*穿衣指数*/

            "dressing_advice": "建议着大衣、呢外套加毛衣、卫衣等服装。", /*穿衣建议*/

            "uv_index": "中等", /*紫外线强度*/

            "comfort_index": "",/*舒适度指数*/

            "wash_index": "较适宜", /*洗车指数*/

            "travel_index": "适宜", /*旅游指数*/

            "exercise_index": "较适宜", /*晨练指数*/

            "drying_index": ""/*干燥指数*/

        },

       "future": { /*未来几天天气*/

            "day_20140321": {

                "temperature": "8℃~20℃",

                "weather": "晴转霾",

                "weather_id": {

                    "fa": "00",

                    "fb": "53"

                },

                "wind": "西南风微风",

                "week": "星期五",

                "date": "20140321"

            },

            "day_20140322": {

                "temperature": "9℃~21℃",

                "weather": "霾转多云",

                "weather_id": {

                    "fa": "53",

                    "fb": "01"

                },

                "wind": "东北风微风转东南风微风",

                "week": "星期六",

                "date": "20140322"

            },

       .......

            "day_20140327": {

                "temperature": "11℃~20℃",

                "weather": "阴转多云",

                "weather_id": {

                    "fa": "02",

                    "fb": "01"

                },

                "wind": "南风微风转无持续风向微风",

                "week": "星期四",

                "date": "20140327"

            }

        }

    }

}

 

转载于:https://www.cnblogs.com/rewuyu/p/4013021.html

你可能感兴趣的文章
适用于带文字 和图片的垂直居中方法
查看>>
Part 2 - Fundamentals(4-10)
查看>>
使用Postmark测试后端存储性能
查看>>
NSTextView 文字链接的定制化
查看>>
第五天站立会议内容
查看>>
CentOs7安装rabbitmq
查看>>
(转))iOS App上架AppStore 会遇到的坑
查看>>
解决vmware与主机无法连通的问题
查看>>
做好产品
查看>>
项目管理经验
查看>>
笔记:Hadoop权威指南 第8章 MapReduce 的特性
查看>>
JMeter响应数据出现乱码的处理-三种解决方式
查看>>
获取设备实际宽度
查看>>
图的算法专题——最短路径
查看>>
SQL批量删除与批量插入
查看>>
Notes on <High Performance MySQL> -- Ch3: Schema Optimization and Indexing
查看>>
C语言之一般树
查看>>
懂了很多大道理,却依旧过不好一生
查看>>
手工数据结构系列-C语言模拟队列 hdu1276
查看>>
【PyQt5 学习记录】008:改变窗口样式之二
查看>>