mirror of
https://github.com/czp3009/bilibili-api.git
synced 2026-08-13 22:43:29 +08:00
TODO 登陆验证码
This commit is contained in:
@@ -8,4 +8,4 @@ import java.io.IOException
|
|||||||
*/
|
*/
|
||||||
class BilibiliApiException(
|
class BilibiliApiException(
|
||||||
commonResponse: CommonResponse
|
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")
|
@POST("/api/oauth2/getKey")
|
||||||
fun getKey(): Deferred<GetKeyResponse>
|
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")
|
@POST("/api/v3/oauth2/login")
|
||||||
@FormUrlEncoded
|
@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 的值
|
* 除了 accessToken, 其他全部都是 cookie 的值
|
||||||
*/
|
*/
|
||||||
|
@Suppress("SpellCheckingInspection")
|
||||||
@POST("/api/v2/oauth2/revoke")
|
@POST("/api/v2/oauth2/revoke")
|
||||||
@FormUrlEncoded
|
@FormUrlEncoded
|
||||||
fun revoke(
|
fun revoke(
|
||||||
@Field("DedeUserID") dedeUserId: String,
|
@Field("DedeUserID") dedeUserId: String,
|
||||||
@Field("DedeUserID__ckMd5") ckMd5: String,
|
@Field("DedeUserID__ckMd5") ckMd5: String,
|
||||||
@Suppress("SpellCheckingInspection") @Field("SESSDATA") sessData: String,
|
@Field("SESSDATA") sessData: String,
|
||||||
@Field("access_token") accessToken: String,
|
@Field("access_token") accessToken: String,
|
||||||
@Field("bili_jct") biliJct: String,
|
@Field("bili_jct") biliJct: String,
|
||||||
@Field("sid") sid: String
|
@Field("sid") sid: String
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.hiczp.bilibili.api.retrofit
|
package com.hiczp.bilibili.api.retrofit
|
||||||
|
|
||||||
|
import com.google.gson.JsonElement
|
||||||
import com.google.gson.annotations.SerializedName
|
import com.google.gson.annotations.SerializedName
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -11,10 +12,19 @@ import com.google.gson.annotations.SerializedName
|
|||||||
data class CommonResponse(
|
data class CommonResponse(
|
||||||
@SerializedName("code")
|
@SerializedName("code")
|
||||||
var code: Int, // 0
|
var code: Int, // 0
|
||||||
|
|
||||||
@SerializedName("msg")
|
@SerializedName("msg")
|
||||||
var msg: String?,
|
var msg: String?,
|
||||||
|
|
||||||
@SerializedName("message")
|
@SerializedName("message")
|
||||||
var message: String?,
|
var message: String?,
|
||||||
|
|
||||||
@SerializedName("ts")
|
@SerializedName("ts")
|
||||||
var timestamp: Long // 1550546539
|
var timestamp: Long, // 1550546539
|
||||||
|
|
||||||
|
/**
|
||||||
|
* data 可能是各种类型, 例如 array, object, string
|
||||||
|
*/
|
||||||
|
@SerializedName("data")
|
||||||
|
var data: JsonElement?
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user