mirror of
https://github.com/czp3009/bilibili-api.git
synced 2025-01-20 20:40:42 +08:00
现在通过 BilibiliAPI 可以直接获得账户信息
This commit is contained in:
parent
677cdbad84
commit
34e7ca5043
@ -4,6 +4,7 @@ import com.hiczp.bilibili.api.interceptor.*;
|
||||
import com.hiczp.bilibili.api.live.LiveService;
|
||||
import com.hiczp.bilibili.api.live.socket.LiveClient;
|
||||
import com.hiczp.bilibili.api.passport.PassportService;
|
||||
import com.hiczp.bilibili.api.passport.entity.InfoEntity;
|
||||
import com.hiczp.bilibili.api.passport.entity.LoginResponseEntity;
|
||||
import com.hiczp.bilibili.api.passport.entity.LogoutResponseEntity;
|
||||
import com.hiczp.bilibili.api.passport.entity.RefreshTokenResponseEntity;
|
||||
@ -250,6 +251,27 @@ public class BilibiliAPI implements BilibiliServiceProvider, LiveClientProvider
|
||||
return logoutResponseEntity;
|
||||
}
|
||||
|
||||
public InfoEntity getAccountInfo() throws IOException, LoginException {
|
||||
InfoEntity infoEntity = getPassportService()
|
||||
.getInfo(bilibiliAccount.getAccessToken())
|
||||
.execute()
|
||||
.body();
|
||||
switch (infoEntity.getCode()) {
|
||||
case ServerErrorCode.Common.OK: {
|
||||
|
||||
}
|
||||
break;
|
||||
case ServerErrorCode.Passport.NO_LOGIN: {
|
||||
throw new LoginException("no login");
|
||||
}
|
||||
default: {
|
||||
throw new IOException(infoEntity.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
return infoEntity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LiveClient getLiveClient(long showRoomId) {
|
||||
return bilibiliAccount.getUserId() == null ?
|
||||
|
Loading…
Reference in New Issue
Block a user