-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
注册、登录接口 #1
Comments
基本约定请求采用表单 post 的形式,返回结果为 json 的形式,application/json。形如: {
"resultCode":0,
"resultData":{
"id":"PeaoZVgQ6ySF5rVF",
"username":"lzwjava",
"mobilePhoneNumber":"13261630925",
"avatarUrl":"https:\/\/avatars2.githubusercontent.com\/u\/5022872?v=3&s=460",
"sessionToken":"Kli8Evtw3bIlD0VTUw7tHeAESSJOAfTK",
"created":"2015-12-01 17:49:46",
"type":"0"
},
"resultInfo":null
} 请求成功的时候,http code 为 200,失败为 400。resultCode 为 0 时,表明成功,resultData 具体请求的数据。当失败时, resultCode 不为 0,具体错误信息在 resultInfo 里。目前有这个几个出错信息。用户名已被占用等。 基本的 host 现在为 请求验证码:没提供手机号时: resultInfo 是 注册返回:
这里如果 smsCode 为 5555 的话,则不去检查验证码,方便调试用。 登录获取当前登录用户(Web 用)删除用户(调试用)@NextCodeReview/staff |
https://www.getpostman.com/collections/01e977765f779f27c62e 这里有 postman 的请求,直接打开即可导入到 postman |
因为 @codingdie 徐芃的建议。把业务逻辑上的错误和 HTTP 的错误分开来。所以当“用户名已被占用”类似的逻辑错误时, HTTP Code 从 400 改为了 200,所以 iOS 要在 successBlock 里对 statusCode 进行判断。 |
登录之后的token只有在创建订单的时候才有用? |
目前用在多个地方,更新用户名及头像,创建订单,找订单列表等。凡是需要知道当前用户都从token 来读取,而不需要传入 userId 的参数。
是的,目前 header 里也是支持的。目前是先从 cookie 里读取 这样写的代码: protected function requestToken()
{
if (isset($_COOKIE["crtoken"])) {
$token = $_COOKIE["crtoken"];
} else {
$token = $this->input->get_request_header("X-CR-Session", TRUE);
}
return $token;
} 所以,在 web 的话,cookie 服务器这边会设置,不用做其它处理。iOS 客户端的话,如果登录了,每次请求都要加上 |
因为 可以统一将以上的 host 将改为此域名。 @zangqilong198812 @NextCodeReview/staff |
第一版接口,删了The text was updated successfully, but these errors were encountered: