在登录阳光沙滩的时候,我拿到了图灵验证码的值,如下所示:
ServiceCreator.create<LoginServices>().getTuringCode(code).enqueue(object : Callback<ResponseBody> {
override fun onResponse(
call: Call<ResponseBody>,
response: Response<ResponseBody>
) {
//从header中拿到图灵码的值
val turingValue = response.headers().get("l_c_i")
if (turingValue != null) {
continuation.resume(turingValue)
} else {
continuation.resumeWithException(RuntimeException("turing code value is $turingValue"))
}
}
override fun onFailure(call: Call<ResponseBody>, t: Throwable) {
continuation.resumeWithException(t)
}
})
然后通过@Header注解的方式将图灵值添加到请求头,如下所示:
//登录接口
@POST("uc/user/login/{captcha}")
fun login(
@Header("l_c_i") turingValue: String,
@Path("captcha") turingCode: String,
@Body loginParams: SubmitLogin.LoginParams
): Call<BaseResponse<Any>>
但是并没有成功,通过调试发现返回的结果依旧是 “ 人类验证码不正确 ” ,如下图所示:
有知道的小伙伴能指点一下嘛,谢谢!
header注解用得比较少,没试过。因为我们几个都是用拦截器加入头部的,但是理论上应该是一样的,注解也是可以的。
我建议你加一个日志拦截器(或者抓包也行) 把你的请求打印出来看看 你的请求头应该是没有带上去的
使用