登录验证
密码登录
login_password:使用账号已保存的密码尝试登录。
const LoginResult *login_password(uint64_t self_id, const char *platform);
void free_login_result(const LoginResult *result);- 权限:
login_password - 调用要求:会等待服务器回应,请在工作线程中调用
参数
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
self_id | uint64_t | 是 | 目标 Account 的 self_id |
platform | const char * | 是 | 目标 Account 的 platform |
使用说明
不使用已保存的登录凭据;未保存密码、授权到期或未开通时失败。
返回值 LoginResult
用完必须调用 free_login_result(result) 交还;客户端未提供接口时返回 NULL。
| 字段 | 类型 | 说明 |
|---|---|---|
code | int32_t | 登录服务返回码;本地失败时为 RESULT_LOCAL_ERROR(-1) |
attempt_id | const char * | 本次登录会话号,续登接口(submit_captcha / send_sms / submit_sms)必须原样传回 |
url | const char * | 滑块或设备验证地址,无内容时为 "" |
country_code | const char * | 短信验证手机区号,可能为空 |
mobile | const char * | 短信验证打码手机号,可能为空 |
resend_after | uint32_t | 短信验证多少秒后可重发 |
msg | const char * | 服务端原始提示/错误文案,本地失败时为本地原因 |
结果判定规则
- 仅当
code == 0且attempt_id为空字符串时,才表示已上线;不能仅凭code == 0判断登录完成。 code == 2且attempt_id非空:打开url完成滑块,将取得的ticket交给submit_captcha。code == 160或239、attempt_id非空且url为空:可调用send_sms下发短信,再调用submit_sms提交验证码(country_code/mobile可能为空,不能仅凭有没有手机号判断是否需要短信)。send_sms返回code == 0且attempt_id非空:仅表示短信下发成功,仍须用同次self_id/platform/attempt_id调用submit_sms。- 设备或身份验证提供
url时,不能将其验证码结果混用于登录滑块;submit_captcha/send_sms/submit_sms不是通用设备验证完成接口。 - 每次续登后均须重新检查
LoginResult;如需取消登录,调用offline_account。