mirror of
https://github.com/czp3009/bilibili-api.git
synced 2024-12-21 20:30:28 +08:00
增加 PassportService.getCaptcha 的快捷调用
This commit is contained in:
parent
33c8c8ad6f
commit
6720bf3798
@ -1,5 +1,6 @@
|
||||
package com.hiczp.bilibili.api.live;
|
||||
|
||||
import com.hiczp.bilibili.api.BilibiliClientProperties;
|
||||
import com.hiczp.bilibili.api.live.entity.*;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.http.*;
|
||||
@ -63,7 +64,7 @@ public interface LiveService {
|
||||
Call<SendOnlineHeartResponseEntity> sendOnlineHeart(@Field("room_id") long roomId, @Field("scale") String scale);
|
||||
|
||||
default Call<SendOnlineHeartResponseEntity> sendOnlineHeart(long roomId) {
|
||||
return sendOnlineHeart(roomId, "xxhdpi");
|
||||
return sendOnlineHeart(roomId, BilibiliClientProperties.defaultSetting().getScale());
|
||||
}
|
||||
|
||||
@POST("api/sendmsg")
|
||||
|
@ -17,8 +17,12 @@ import javax.annotation.Nullable;
|
||||
public interface PassportService {
|
||||
//获取验证码
|
||||
default okhttp3.Call getCaptcha(@Nonnull String cookies) {
|
||||
return getCaptcha(cookies, HttpLoggingInterceptor.Level.BASIC);
|
||||
}
|
||||
|
||||
default okhttp3.Call getCaptcha(@Nonnull String cookies, @Nonnull HttpLoggingInterceptor.Level logLevel) {
|
||||
return new OkHttpClient.Builder()
|
||||
.addInterceptor(new HttpLoggingInterceptor().setLevel(HttpLoggingInterceptor.Level.BASIC))
|
||||
.addInterceptor(new HttpLoggingInterceptor().setLevel(logLevel))
|
||||
.build()
|
||||
.newCall(
|
||||
new Request.Builder()
|
||||
|
@ -26,20 +26,24 @@ public class RuleSuite {
|
||||
public static ExternalResource externalResource = new ExternalResource() {
|
||||
@Override
|
||||
protected void before() throws Throwable {
|
||||
//初始化 slf4j
|
||||
BasicConfigurator.configure();
|
||||
//读取配置文件
|
||||
try {
|
||||
Config.setConfig(
|
||||
new Gson().fromJson(
|
||||
new BufferedReader(new InputStreamReader(Config.class.getResourceAsStream("/config.json"))),
|
||||
Config.class
|
||||
)
|
||||
);
|
||||
} catch (NullPointerException e) {
|
||||
//抛出异常就可以取消测试
|
||||
throw new RuntimeException("Please create config file before tests");
|
||||
}
|
||||
init();
|
||||
}
|
||||
};
|
||||
|
||||
public static void init() {
|
||||
//初始化 slf4j
|
||||
BasicConfigurator.configure();
|
||||
//读取配置文件
|
||||
try {
|
||||
Config.setConfig(
|
||||
new Gson().fromJson(
|
||||
new BufferedReader(new InputStreamReader(Config.class.getResourceAsStream("/config.json"))),
|
||||
Config.class
|
||||
)
|
||||
);
|
||||
} catch (NullPointerException e) {
|
||||
//抛出异常就可以取消测试
|
||||
throw new RuntimeException("Please create config file before tests");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user