登录、注册、注销文档
益安
1. 登录获取Token
Method and URL Structure
| Method |
Resource URL |
| POST |
/account/login/ |
Request Parameters
| Name |
Description |
Required |
Default |
| username |
用户名 |
YES |
|
| password |
密码 |
YES |
|
Request
{ "username":"18012345678", "password":"abcd3993a",}
cURL Example
$ curl -X POST -d 'username=18012345678&password=abcd3993' http://127.0.0.1:8000/account/login/
JSON Response
{"token":"1d0e52789e7d8e042bc870d359605344747b5216"}
2. 退出登录并清除Token
退出登录后Backend清除Token,这个Token不能再用作Authen。
Method and URL Structure
| Method |
Resource URL |
| PUT |
/account/logout/ |
| Name |
Description |
Required |
Default |
| Authorization |
Token 1d0e52789e7d8e042bc870d359605344747b5216 |
Yes |
|
*Authorization的值为登录成功后返回值
cURL Example
$ curl -X PUT -H 'Authorization: Token 1d0e52789e7d8e042bc870d359605344747b5216'\http://127.0.0.1:8000/account/logout/
JSON Response
{"status":0, "message":""}
0. 用户注册(appuser)
Method and URL Structure
| Method |
Resource URL |
| POST |
/account/signup/ |
Request Parameters
| Name |
Description |
Required |
Default |
| profile |
用户信息 |
Yes |
{} |
| username |
注册账号 |
Yes |
|
| password |
注册密码 |
Yes |
|
cURL Example
curl -X POST -d '{"profile":{},"username":"13ea990209b7b83856b69fa9cc", "password":"123456"}' 127.0.0.1:8000/account/appuser/
JSON Response
{"token":"436bad6e50ff8ff92bae5395fb823e3f9af49a79"}
3. 用户注册
Method and URL Structure
| Method |
Resource URL |
| POST |
/account/signup/ |
Request Parameters
| Name |
Description |
Required |
Default |
| profile |
用户信息 |
Yes |
{} |
| username |
注册账号 |
Yes |
|
| password |
注册密码 |
Yes |
|
| verification_code |
验证码 |
Yes |
|
cURL Example
$ curl -X POST -d '{"profile":{},"username":"15201052252", "password":"123456", "verification_code":"882104"}' 127.0.0.1:8000/account/signup/
JSON Response
{"token":"436bad6e50ff8ff92bae5395fb823e3f9af49a79"}
4. 用户获取验证码(注册)
Method and URL Structure
| Method |
Resource URL |
| GET |
/account/signup/ |
Request Parameters
| Name |
Description |
Required |
Default |
| username |
注册账号 |
Yes |
|
cURL Example
$ curl -X GET 127.0.0.1:8000/account/signup/?username=15201052252
JSON Response
{"status":0,"message":""}
5. 用户获取验证码(修改密码)
Method and URL Structure
| Method |
Resource URL |
| GET |
/account/update/ |
Request Parameters
| Name |
Description |
Required |
Default |
| username |
注册账号 |
Yes |
|
cURL Example
$ curl -X GET 127.0.0.1:8000/account/update/?username=15201052252
JSON Response
{"status":0,"message":""}
6. 用户修改密码
Method and URL Structure
| Method |
Resource URL |
| PUT |
/account/update/ |
Request Parameters
| Name |
Description |
Required |
Default |
| username |
注册账号 |
Yes |
|
| verification_code |
验证码 |
Yes |
|
| password |
密码 |
Yes |
|
| profile |
个人信息 |
Yes |
{} |
cURL Example
$ curl -X PUT -d '{"profile":{},"username":"15201052252", "password":"123456", "verification_code":"882104"}' 127.0.0.1:8000/account/update/
JSON Response
{ "pk": 2, "username": "15201052252", "password": "123456", "profile": { "pk": 1, "username": "15201052252", "nickname": "晓辰", "location": "河南新乡", "avatar_url": "http://123.jpg", "website": "http://123.html", "point": 41, "birthday": "1993-09-22", "level": "fresh", "level_display": "益安新人", "credit": 28, "credit_level": "pupil", "credit_level_display": "益安小学生", "account": "181.00", "sex": "secret", "code": "100000", "email": "chen158_7@buy.com", "phone": "15201052252" }}
5. 修改个人信息
Description
用户修改课程信息
Method and URL Structure
| Method |
Resource URL |
| PUT |
/account/profile_detail/ |
Request Parameters
| Name |
Description |
Required |
Default |
| nickname |
昵称 |
No |
|
| avatar_url |
头像 |
No |
|
| location |
地址 |
No |
|
| website |
个人网站 |
No |
|
| birthday |
生日 |
No |
|
| sex |
性别 |
NO |
|
| code |
邮编 |
NO |
|
| email |
邮箱 |
NO |
|
| phone |
固定电话 |
NO |
|
| Name |
Description |
Required |
Default |
| Authorization |
Token 7309fabd207c22e0a00eada158989b89ffe839ef |
Yes |
|
*Authorization的值为登录成功后返回值
Request
{ "nickname":"晓辰", "location":"河南新乡", "avatar_url":"http://123.jpg", "website":"http://123.html", "birthday":"05-18",}
cURL Example
curl -X PUT -H 'Authorization: Token 7309fabd207c22e0a00eada158989b89ffe839ef' -d 'nickname=晓辰&location=河南新乡&avatar_url=http://123.jpg&website=http://123.html&birthday=05-18' http://127.0.0.1:8000/account/profile_detail/
JSON Response Parameters
- level:未知等级(unkown)、益安小黑屋(black)、益安新人(fresh)、益安初级会员(junior)、益安中级会员(middle)、益安高级会员(senior)、益安明星会员(star)、益安金牌会员(gold)、益安元老会员(old)
- credit_level:未知等级(unkown)、益安新生(fresh)、益安小学生(pupil)、益安初中生(junior)、益安高中生(senior)、益安专科生(special)、益安本科生(college)、益安硕士生(master)、益安博士生(doctor)、益安博士后(post_doctor)
JSON Response
{ "pk":1, "username":"teacher", "nickname":"晓辰", "location":"河南新乡", "avatar_url":"http://123.jpg", "website":"http://123.html" "birthday":"1993-05-18", "level":"fresh", "point":10, "level_display":"益安新人", "credit":3, "credit_level":"fresh", "credit_level_display":"益安新生", "account":"0.00", "sex": "secret", "code": "100000", "email": "chen158_7@buy.com", "phone": "15201052252"}
6. 查看个人信息
Description
用户查询个人资料
Method and URL Structure
| Method |
Resource URL |
| GET |
/account/profile_detail/ |
| Name |
Description |
Required |
Default |
| Authorization |
Token 7309fabd207c22e0a00eada158989b89ffe839ef |
Yes |
|
*Authorization的值为登录成功后返回值
cURL Example
curl -X GET -H 'Authorization: Token 7309fabd207c22e0a00eada158989b89ffe839ef' http://127.0.0.1:8000/account/profile_detail/
JSON Response
{ "pk": 1, "username": "15201052252", "nickname": "晓辰", "location": "河南新乡", "avatar_url": "http://123.jpg", "website": "http://123.html", "point": 41, "birthday": "1993-09-22", "level": "fresh", "level_display": "益安新人", "credit": 28, "credit_level": "pupil", "credit_level_display": "益安小学生", "account": "181.00", "sex": "secret", "code": "100000", "email": "chen158_7@buy.com", "phone": "15201052252"}
7. 签到
Description
用户每天签到
Method and URL Structure
| Method |
Resource URL |
| POST |
/account/signin/ |
| Name |
Description |
Required |
Default |
| Authorization |
Token 7309fabd207c22e0a00eada158989b89ffe839ef |
Yes |
|
*Authorization的值为登录成功后返回值
cURL Example
curl -X POST -H 'Authorization: Token 706a87288233ea2427cddb8a1bbce29369ac5073' http://127.0.0.1:8000/account/signin/
JSON Response
{ "username":"15201052252", "action":"birthday", "value":2, "create_time":"2016-05-18T10:33:06.377551Z", "point":13}
8. 观看产品
Description
用户观看产品
Method and URL Structure
| Method |
Resource URL |
| POST |
/education/video_watch_history/ |
Request Parameters
| Name |
Description |
Required |
Default |
| video |
视频的id/pk |
Yes |
|
| owner |
用户的id/pk |
Yes |
|
| Name |
Description |
Required |
Default |
| Authorization |
Token 7309fabd207c22e0a00eada158989b89ffe839ef |
Yes |
|
*Authorization的值为登录成功后返回值
cURL Example
curl -X POST -H 'Authorization: Token 706a87288233ea2427cddb8a1bbce29369ac5073' -d 'video=1&owner=2' http://127.0.0.1:8000/education/video_watch_history/
JSON Response
{ "pk":3, "owner":2, "video":1, "create_time":"2016-05-19T06:57:45.288207Z",}
9. 查看本月签到信息
Description
用户查看本月的签到信息
Method and URL Structure
| Method |
Resource URL |
| GET |
/account/signin/ |
| Name |
Description |
Required |
Default |
| Authorization |
Token 7309fabd207c22e0a00eada158989b89ffe839ef |
Yes |
|
*Authorization的值为登录成功后返回值
cURL Example
curl -X GET -H 'Authorization: Token 706a87288233ea2427cddb8a1bbce29369ac5073' http://127.0.0.1:8000/account/signin/
JSON Response
[ { "pk":8, "username":"15670502158", "action":"sin-in", "value":1, "create_time":"2016-06-03T05:38:41.493577Z", "point":11 }]