每天学一句英语
# 接口信息
- 接口状态 : 正常
- 请求方式 :
GET
- 返回格式 :
JSON
- 扣除Gong币数 :
1
# 请求地址
http://gateway.gtcbaba.icu/api/english
1
# 请求参数
参数名 | 必选 | 类型 | 描述 |
---|---|---|---|
无 | 否 | string | 直接请求即可 |
# 响应参数
参数名称 | 类型 | 描述 |
---|---|---|
code | int | 响应码 |
data.zh | string | 中文翻译 |
data.en | string | 英文短句 |
data.pic | string | 配图url地址 |
message | string | 响应描述 |
# 代码示例
注意 🔔️
没有开发者调用凭证无法调用接口哦!!! 前往个人中心获取开发者凭证 (opens new window)
注入Manager
@Resource
private GtcApiManager gtcApiManager;
1
2
2
- 示例一 :推荐👍
通过yml配置开发者调用凭证
public BasicResponse getEnglish() {
BasicResponse englishInfo = null;
try {
englishInfo = gtcApiManager.getEnglish();
System.out.println("得到英语句子信息: " + englishInfo);
} catch (ApiException e) {
log.error(e.getMessage());
}
return englishInfo;
}
1
2
3
4
5
6
7
8
9
10
2
3
4
5
6
7
8
9
10
- 示例二:不推荐👎
手动实例化
public BasicResponse getEnglish() {
GtcApiClient client = new GtcApiClient("您的AccessKey", "您的SecretKey");
GtcApiManager gtcApiManager = new GtcApiManager();
gtcApiManager.setGtcApiClient(client);
BasicResponse englishInfo = null;
try {
englishInfo = gtcApiManager.getEnglish();
System.out.println("得到英语句子信息: " + englishInfo);
} catch (ApiException e) {
log.error(e.getMessage());
}
return englishInfo;
}
1
2
3
4
5
6
7
8
9
10
11
12
13
2
3
4
5
6
7
8
9
10
11
12
13
响应示例:
{
"zh": "这世界上凡是值得拥有的东西,都不易获得。",
"en": "Nothing in this world that's worth having comes easy.",
"pic": "https://staticedu-wps.cache.iciba.com/image/5d786d9265a8ab5afd6756a5644c52e4.jpg"
}
1
2
3
4
5
2
3
4
5