注册和登录
金色童年
验证身份的方式
使用 TokenAuthentication 验证身份。登录后获取 token, 在 HTTP heard 中指定 token:
Authorization: token 9944b09199c62bcf9418ad846dd0e4bbdfc6ee4b
cURL Example
curl -X GET http://localhost/api/example/ -H 'Authorization: Token 9944b09199c62bcf9418ad846dd0e4bbdfc6ee4b'
获取注册验证码
用手机号作 username
Method and URL Structure
| Method |
Resource URL |
| GET |
/account/signup_request/ |
Request Paramaters
| Name |
Descript |
Required |
Default |
| username |
用户名 |
YES |
|
| key |
图片验证码 |
YES |
|
| hashkey |
captcha hash key |
Yes |
|
cURL Example
curl http://localhost/account/signup_request/?username=15716098745&key=abcd&haskey=zcuq6z6pnwqirwuq49r9oe06tr5zxw6v
Response
{"message": "", "status": 0}
用验证码注册用户
Method and URL Structure
| Method |
Resource URL |
| POST |
/account/signup/ |
Request Data
| Name |
Description |
Required |
Default |
| username |
用户名 |
YES |
|
| password |
密码 |
YES |
|
| verification_code |
验证码 |
YES |
|
| related_shop_id |
关联的店铺 |
NO |
|
cURL Example
$ curl -X POST -H 'Content-Type: Application/json' --data '{"username": "13245678910", "password": "laKNh5DBsW", "verfication_code": "123456"} \http://localhost/account/signup/
Reponse
{"token": "9944b09199c62bcf9418ad846dd0e4bbdfc6ee4b"}
登录用户
可多次登录,每次登录获取一个新token,上次的token 不失效。
Method and URL Structure
| Method |
Resource URL |
| POST |
/account/login/ |
Request Data
| Name |
Description |
Required |
Default |
| username |
用户名 |
YES |
|
| password |
密码 |
YES |
|
cURL Example
$ curl -X POST -H 'Content-Type: Application/json' --data '{"username": "13245678910", "password": "laKNh5DBsW"} \http://localhost/account/login/
Reponse
{"token": "9944b09199c62bcf9418ad846dd0e4bbdfc6ee4b"}