获取随机壁纸
# 接口信息
- 接口状态 : 正常
- 请求方式 :
GET
- 返回格式 :
JSON
- 扣除积分数 :
1
# 请求地址
https://apigw.caiths.com/api/randomWallpaper
1
# 请求参数
参数名 | 必选 | 类型 | 描述 |
---|---|---|---|
method | 否 | string | 输出壁纸端mobile、pc、zsy默认为pc |
lx | 否 | string | 输出分类meizi、dongman、fengjing、suiji,为空随机输出 |
# 响应参数
参数名称 | 类型 | 描述 |
---|---|---|
code | int | 响应码 |
data.imgurl | string | 随机图片地址url |
message | string | 响应描述 |
# 代码示例
注意 🔔️
没有开发者调用凭证无法调用接口哦!!! 前往获取开发者凭证 (opens new window)
注入Service
@Resource
private ApiService apiService;
1
2
2
- 示例一 :推荐👍
通过yml配置开发者调用凭证
@GetMapping("/randomWallpaper")
public ResultResponse getRandomWallpaper(RandomWallpaperParams randomWallpaperParams) {
ResultResponse resultResponse;
try {
RandomWallpaperRequest randomWallpaperRequest = new RandomWallpaperRequest();
randomWallpaperRequest.setRequestParams(randomWallpaperParams);
resultResponse = apiService.getRandomWallpaper(randomWallpaperRequest);
} catch (ApiException e) {
throw new BusinessException(e.getCode(), e.getMessage());
}
return resultResponse;
}
1
2
3
4
5
6
7
8
9
10
11
12
2
3
4
5
6
7
8
9
10
11
12
响应示例:
{
"imgurl": "https://img.btstu.cn/api/images/5b16259a96cbc.jpg"
}
1
2
3
2
3
- 示例二:推荐👍
搭配SwiftWeb (opens new window)快速开发Web项目
@GetMapping("/randomWallpaper/easyWeb")
public BaseResponse<ResultResponse> getRandomWallpaperEasyWeb(RandomWallpaperParams randomWallpaperParams) {
ResultResponse resultResponse;
try {
RandomWallpaperRequest randomWallpaperRequest = new RandomWallpaperRequest();
randomWallpaperRequest.setRequestParams(randomWallpaperParams);
resultResponse = apiService.getRandomWallpaper(randomWallpaperRequest);
} catch (ApiException e) {
throw new BusinessException(e.getCode(), e.getMessage());
}
return ResultUtils.success(resultResponse);
}
1
2
3
4
5
6
7
8
9
10
11
12
2
3
4
5
6
7
8
9
10
11
12
响应示例:
{
"code": 0,
"data": {
"imgurl": "https://img.btstu.cn/api/images/5b35a4886fd85.jpg"
},
"message": "ok"
}
1
2
3
4
5
6
7
2
3
4
5
6
7
- 示例三:
@GetMapping("/randomWallpaper/setKey")
public ResultResponse getRandomWallpaperSetKey(RandomWallpaperParams randomWallpaperParams) {
ResultResponse resultResponse;
CaiApiClient caiApiClient = new CaiApiClient("7052a8594339a519e0ba5eb04a267a60", "d8d6df60ab209385a09ac796f1dfe3e1");
try {
RandomWallpaperRequest randomWallpaperRequest = new RandomWallpaperRequest();
randomWallpaperRequest.setRequestParams(randomWallpaperParams);
resultResponse = apiService.getRandomWallpaper(caiApiClient, randomWallpaperRequest);
} catch (ApiException e) {
throw new BusinessException(e.getCode(), e.getMessage());
}
return resultResponse;
}
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
# 更多示例详见:Cai-API-SDK-Demo 示例项目 (opens new window)
帮助我们改善此页面! (opens new window)
上次更新: 2025/01/10, 01:30:24