mirror of
https://github.com/czp3009/bilibili-api.git
synced 2025-02-19 20:50:28 +08:00
TODO 登陆验证码
This commit is contained in:
parent
192b6cd9ac
commit
16dcf58dd6
@ -8,4 +8,4 @@ import java.io.IOException
|
||||
*/
|
||||
class BilibiliApiException(
|
||||
commonResponse: CommonResponse
|
||||
) : IOException(commonResponse.msg ?: commonResponse.message)
|
||||
) : IOException(commonResponse.message?.takeIf { it.isNotEmpty() } ?: commonResponse.msg)
|
||||
|
@ -14,19 +14,30 @@ interface PassportAPI {
|
||||
@POST("/api/oauth2/getKey")
|
||||
fun getKey(): Deferred<GetKeyResponse>
|
||||
|
||||
/**
|
||||
* 多次错误的登陆尝试后, 服务器将返回 {"ts":1550569982,"code":-105,"data":{"url":"https://passport.bilibili.com/register/verification.html?success=1>=b6e5b7fad7ecd37f465838689732e788&challenge=9a67afa4d42ede71a93aeaaa54a4b6fe&ct=1&hash=105af2e7cc6ea829c4a95205f2371dc5"},"message":"验证码错误!"}
|
||||
*/
|
||||
@Suppress("SpellCheckingInspection")
|
||||
@POST("/api/v3/oauth2/login")
|
||||
@FormUrlEncoded
|
||||
fun login(@Field("username") username: String, @Field("password") password: String): Deferred<LoginResponse>
|
||||
fun login(
|
||||
@Field("username") username: String, @Field("password") password: String,
|
||||
//以下为验证码所需字段
|
||||
@Field("challenge") challenge: String? = null, //系统给出的滑动验证 ID
|
||||
@Field("seccode") secCode: String? = null, //用户给出的滑动验证答案, 生成算法不明
|
||||
@Field("validate") validate: String? = null //滑动验证校验字段, 算法不明
|
||||
): Deferred<LoginResponse>
|
||||
|
||||
/**
|
||||
* 除了 accessToken, 其他全部都是 cookie 的值
|
||||
*/
|
||||
@Suppress("SpellCheckingInspection")
|
||||
@POST("/api/v2/oauth2/revoke")
|
||||
@FormUrlEncoded
|
||||
fun revoke(
|
||||
@Field("DedeUserID") dedeUserId: String,
|
||||
@Field("DedeUserID__ckMd5") ckMd5: String,
|
||||
@Suppress("SpellCheckingInspection") @Field("SESSDATA") sessData: String,
|
||||
@Field("SESSDATA") sessData: String,
|
||||
@Field("access_token") accessToken: String,
|
||||
@Field("bili_jct") biliJct: String,
|
||||
@Field("sid") sid: String
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.hiczp.bilibili.api.retrofit
|
||||
|
||||
import com.google.gson.JsonElement
|
||||
import com.google.gson.annotations.SerializedName
|
||||
|
||||
/**
|
||||
@ -11,10 +12,19 @@ import com.google.gson.annotations.SerializedName
|
||||
data class CommonResponse(
|
||||
@SerializedName("code")
|
||||
var code: Int, // 0
|
||||
|
||||
@SerializedName("msg")
|
||||
var msg: String?,
|
||||
|
||||
@SerializedName("message")
|
||||
var message: String?,
|
||||
|
||||
@SerializedName("ts")
|
||||
var timestamp: Long // 1550546539
|
||||
var timestamp: Long, // 1550546539
|
||||
|
||||
/**
|
||||
* data 可能是各种类型, 例如 array, object, string
|
||||
*/
|
||||
@SerializedName("data")
|
||||
var data: JsonElement?
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user