[关闭]
@fuyb1986 2017-05-18T06:51:37.000000Z 字数 1427 阅读 641

注册和登录

冰橙课件


验证身份的方式

使用 TokenAuthentication 验证身份。登录后获取 token, 在 HTTP heard 中指定 token:

  1. Authorization: token 9944b09199c62bcf9418ad846dd0e4bbdfc6ee4b

cURL Example

  1. curl -X GET http://localhost/api/example/ -H 'Authorization: Token 9944b09199c62bcf9418ad846dd0e4bbdfc6ee4b'

获取注册验证码

用手机号作 username

Method and URL Structure

Method Resource URL
GET /api/account/signup_request/

Request Paramaters

Name Descript Required Default
username 用户名 YES
key 图片验证码 YES
hashkey captcha hash key YES

cURL Example

  1. curl -X GET -H "Content-Type: application/json" http://localhost/api/account/signup_request/?username=15716098745&key=abcd&haskey=zcuq6z6pnwqirwuq49r9oe06tr5zxw6v

Response

  1. {"message": "", "status": 0}

用验证码注册用户

Method and URL Structure

Method Resource URL
POST /api/account/signup/

Request Data

Name Description Required Default
username 用户名 YES
password 密码 YES
verification_code 验证码 YES
group 教师(teacher)/学生(student) YES

cURL Example

  1. $ curl -X POST -H "Content-Type: application/json" --data '{"username": "13245678910", "password": "laKNh5DBsW", "verfication_code": "123456"} \
  2. http://localhost/api/account/signup/

Reponse

  1. {"token": "9944b09199c62bcf9418ad846dd0e4bbdfc6ee4b"}

登录用户

可多次登录,每次登录获取一个新token,上次的token 不失效。

Method and URL Structure

Method Resource URL
POST /api/account/login/

Request Data

Name Description Required Default
username 用户名 YES
password 密码 YES

cURL Example

  1. $ curl -X POST -H "Content-Type: application/json" --data '{"username": "13245678910", "password": "laKNh5DBsW"}' \
  2. http://localhost/api/account/login/

Reponse

  1. {"token": "9944b09199c62bcf9418ad846dd0e4bbdfc6ee4b"}
添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注