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

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

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

    • 简 介
    • 安 装
    • 快速开始
      • 👌 新手需知
      • 📦 安 装
        • 🍊 Maven
        • ⚙️ 配置客户端
        • 1. 前往Gong-API 接口开放平台 获取开发者密钥(AccessKey、SecretKey)
        • 2. 初始化GtcApiClient客户端对象
        • 3. 注入API服务对象
        • 4. 发起请求
      • 🐞 提供BUG反馈或建议
    • 返回响应码
  • API接口

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

快速开始

# 👌 新手需知

  • 拥有 Java 开发环境以及相应 IDE
  • 熟悉 Spring Boot
  • 熟悉 Maven

# 📦 安 装

# 🍊 Maven

在项目的pom.xml的dependencies中加入以下内容

<dependency>
  <groupId>io.github.gtcbaba</groupId>
  <artifactId>gtcapi-client-sdk</artifactId>
  <version>0.0.2</version>
</dependency>
1
2
3
4
5

提示 🔔️

JDK 8 +

# ⚙️ 配置客户端

# 1. 前往Gong-API 接口开放平台 (opens new window) 获取开发者密钥(AccessKey、SecretKey)

# 2. 初始化GtcApiClient客户端对象

  • 方法 1 :通过配置文件注入对象(推荐)

    • yml / yaml

      # 在application.yml中配置如下
      gtcapi:
        client:
          client:
            access-key: 你的 accessKey
            secret-key: 你的 secretKey
      
      1
      2
      3
      4
      5
      6
  • 方法 2 :手动实例化客户端(不推荐)

    String accessKey = "你的 accessKey";
    String secretKey = "你的 secretKey";
    GtcApiClient client = new GtcApiClient(accessKey, secretKey);
    GtcApiManager gtcApiManager = new GtcApiManager();
    gtcApiManager.setGtcApiClient(client);
    
    1
    2
    3
    4
    5

# 3. 注入API服务对象

 @Resource
 private GtcApiManager gtcApiManager;
 
 
 /**
   注意: 
     必须是第一种配置文件注入的方式,才可以通过@Resource注解直接得到Manager对象并使用
     如果是第二种手动实例化的方式,则不可以通过@Resource注解得到Manager对象,必须先setGtcApiClient后才可以正常使用。
     第二种方式代码冗余且容易出错,因此不推荐!
 **/
1
2
3
4
5
6
7
8
9
10

# 4. 发起请求

示例:随机土味情话

  • 示例(方法一) :通过配置文件 推荐👍
try {
    BasicResponse sayingInfo = gtcApiManager.getSaying();
    return sayingInfo.getData();
} catch (ApiException e) { //异常处理
    log.error(e.getMessage());
}
1
2
3
4
5
6
  • 示例(方法二) :手动注入 不推荐👎
try {
    GtcApiClient client = new GtcApiClient("你的 accessKey", "你的 secretKey");
    GtcApiManager gtcApiManager = new GtcApiManager();
    gtcApiManager.setGtcApiClient(gtcApiClient);
    BasicResponse sayingInfo = gtcApiManager.getSaying();
    return sayingInfo.getData();
} catch (ApiException e) { //异常处理
    log.error(e.getMessage());
}
1
2
3
4
5
6
7
8
9

响应:

{
  "content": "古往传奇多少别离,我只是不经意遇到了你"
}
1
2
3

# 🐞 提供BUG反馈或建议

提交问题反馈请说明正在使用的JDK版本、Qi-API-SDK版本和相关依赖库版本。

  • gtcapi-client-sdk Github Issue (opens new window)
安 装
返回响应码

← 安 装 返回响应码→

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