Gong-API 开发者文档 Gong-API 开发者文档
首页
  • 简 介
  • 安 装
  • 快速开始
  • 返回响应码
  • API接口

    • 网易云新歌榜
    • 手机号所属地区
    • 随机土味情话
    • 星座运势
    • 获取天气信息
    • 获取每日壁纸
    • 生成二维码
    • 智能BI
    • 换个头像吧
    • 你的名字
    • 每天学一句英语
    • 抖音热点榜
  • 使用配置
赞助
GitHub (opens new window)
首页
  • 简 介
  • 安 装
  • 快速开始
  • 返回响应码
  • API接口

    • 网易云新歌榜
    • 手机号所属地区
    • 随机土味情话
    • 星座运势
    • 获取天气信息
    • 获取每日壁纸
    • 生成二维码
    • 智能BI
    • 换个头像吧
    • 你的名字
    • 每天学一句英语
    • 抖音热点榜
  • 使用配置
赞助
GitHub (opens new window)
  • 指南

    • 简 介
    • 安 装
    • 快速开始
    • 返回响应码
  • API接口

    • 网易云新歌榜
    • 手机号所属地区
    • 随机土味情话
    • 星座运势
    • 获取天气信息
      • 获取每日壁纸
      • 生成二维码
      • 智能BI🔥
      • 换个头像吧
      • 你的名字
      • 每天学一句英语
      • 抖音热点榜
    目录

    获取天气信息

    # 接口信息

    • 接口状态 : 正常
    • 请求方式 :GET
    • 返回格式 :JSON
    • 扣除Gong币数 :1

    # 请求地址

    http://gateway.gtcbaba.icu/api/weather
    
    1

    # 请求参数

    参数名 必选 类型 描述
    city 否 string 输入城市或县区
    ip 否 string 输入IP地址
    type 否 string 默认一天,可配置为week获取这周的天气信息

    # 响应参数

    参数名称 类型 描述
    code int 响应码
    data.city string 城市
    data.info.date string 日期
    data.info.week string 星期几
    data.info.type string 天气类型
    data.info.low string 最低温度
    data.info.high string 最高温度
    data.info.fengxiang string 风向
    data.info.fengli string 风力
    data.info.night.type string 夜间天气类型
    data.info.night.fengxiang string 夜间风向
    data.info.night.fengli string 夜间风力
    data.air.aqi int 空气质量指数
    data.air.aqi_level int 空气质量指数级别
    data.air.aqi_name string 空气质量指数名称
    data.air.co string 一氧化碳浓度
    data.air.no2 string 二氧化氮浓度
    data.air.o3 string 臭氧浓度
    data.air.pm10 string PM10浓度
    data.air.pm25 string PM2.5浓度
    data.air.so2 string 二氧化硫浓度
    data.tip string 提示信息
    message string 响应描述

    # 代码示例

    注意 🔔️

    没有开发者调用凭证无法调用接口哦!!! 前往个人中心获取开发者凭证 (opens new window)

    注入Manager

    @Resource
    private GtcApiManager gtcApiManager;
    
    1
    2
    • 示例一 :推荐👍

    通过yml配置开发者调用凭证

    public BasicResponse getWeather() {
        WeatherParams weatherParams = new WeatherParams();
        weatherParams.setCity("南京");
        WeatherRequest weatherRequest = new WeatherRequest();
        weatherRequest.setRequestParams(weatherParams);
        BasicResponse weatherInfo = null;
        try {
            weatherInfo = gtcApiManager.getWeatherInfo(weatherRequest);
            System.out.println("得到天气信息: " + weatherInfo);
        } catch (ApiException e) {
            log.error(e.getMessage());
        }
        return weatherInfo;
    }
    
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    • 示例二:不推荐👎

    手动实例化

    public BasicResponse getWeather() {
        GtcApiClient client = new GtcApiClient("您的AccessKey", "您的SecretKey");
        GtcApiManager gtcApiManager = new GtcApiManager();
        gtcApiManager.setGtcApiClient(client);
        WeatherParams weatherParams = new WeatherParams();
        weatherParams.setCity("南京");
        WeatherRequest weatherRequest = new WeatherRequest();
        weatherRequest.setRequestParams(weatherParams);
        BasicResponse weatherInfo = null;
        try {
            weatherInfo = gtcApiManager.getWeatherInfo(weatherRequest);
            System.out.println("得到天气信息: " + weatherInfo);
        } catch (ApiException e) {
            log.error(e.getMessage());
        }
        return weatherInfo;
    }
    
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17

    响应示例:

    {
      "city": "徐州市",
      "info": {
        "date": "2024-08-02",
        "week": "星期五",
        "type": "阴",
        "low": "28°C",
        "high": "36°C",
        "fengxiang": "西风",
        "fengli": "3-4级",
        "night": {
          "type": "晴",
          "fengxiang": "东南风",
          "fengli": "1-3级"
        }
      },
      "air": {
        "aqi": 26,
        "aqi_level": 1,
        "aqi_name": "优",
        "co": "0",
        "no2": "14",
        "o3": "82",
        "pm10": "24",
        "pm2.5": "15",
        "so2": "7"
      },
      "tip": "天太热了,吃个西瓜~"
    }
    
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    星座运势
    获取每日壁纸

    ← 星座运势 获取每日壁纸→

    Theme by Vdoing | Copyright © 2024-2024 gtcbaba
    • 跟随系统
    • 浅色模式
    • 深色模式
    • 阅读模式