登录注册与用户信息
好热闹TeaShop
登录
Method and Url Structure
| Method |
Resource URL |
| POST |
/account/login/ |
Request and Parameters
| Name |
Description |
Required |
Default |
| code |
微信参数 |
YES |
|
Request
{ "code":"1234"}
cURL Example
curl -X POST -d data{...}http://127.0.0.1:8000/account/login/
JSON Response
{ "session": 602501615210}// 注册后回登录会返回 token 信息{ "token": "fcfbbe8f594390a4c28ba4b3a5623c13f1261dd4", "session": 514719800189}
注册
Method and Url Structure
| Method |
Resource URL |
| POST |
/account/signup/ |
Request and Parameters
| Name |
Description |
Required |
Default |
| session |
登录返回信息 |
YES |
|
| nickname |
昵称 |
YES |
|
| avatar_url |
头像 |
YES |
|
| country |
国籍 |
YES |
|
| province |
省 |
YES |
|
| city |
市 |
YES |
|
| sex |
性别 |
NO |
|
Request
{ "session": "602501615210", "nickname": "昵称", "avatar_url": "https://static1.bcjiaoyu.com/head7@3x.png", "country": "呵呵国", "province": "哈哈省", "city": "嘿嘿市"}
cURL Example
curl -X POST -d data{...}http://127.0.0.1:8000/account/signup/
JSON Response
{ "token": "68b76feaa3ec4f9da1ed7cfa6cd97f3d53ecf732"}
查看个人信息
Method and Url Structure
| Method |
Resource URL |
| GET |
/account/whoami |
cURL Example
curl -X GET -H 'Authorization: Token 68b76feaa3ec4f9da1ed7cfa6cd97f3d53ecf732'http://127.0.0.1:8000/account/whoami
JSON Response
{ "pk": 2, "owner": "opSbp2JARhmzgmez9yObTt9aSybs2", "nickname": "昵称", "avatar_url": "https://static1.bcjiaoyu.com/head7@3x.png", "sex": "N", "sex_display": "未知", "country": "呵呵国", "province": "哈哈省", "city": "嘿嘿市"}
查看他人信息
Method and Url Structure
| Method |
Resource URL |
| GET |
/account/profile/&{owner} |
Request and Parameters
| Name |
Description |
Required |
Default |
| owner |
owner |
YES |
|
Request
opSbp1JARhmzgmez9yObTt9aSybs1
cURL Example
curl -X PUT/PATCH -H 'Authorization: Token 68b76feaa3ec4f9da1ed7cfa6cd97f3d53ecf732' -d data{...}http://127.0.0.1:8000/account/profile/opSbp1JARhmzgmez9yObTt9aSybs1/
JSON Response
{ "pk": 1, "owner": "opSbp1JARhmzgmez9yObTt9aSybs1", "nickname": "你瞅啥", "avatar_url": "http://p3.gexing.com/G1/M00/DF/94/rBACFFIuWbCQ5SKSAAAcnnJofuI009_200x200_3.jpg", "sex": "N", "sex_display": "未知", "country": "嘿嘿国", "province": "哈哈省", "city": "呵呵市"}
退出(当前 token 失效)
Method and Url Structure
| Method |
Resource URL |
| POST |
/account/logout/ |
cURL Example
curl -X POST -H 'Authorization: Token 68b76feaa3ec4f9da1ed7cfa6cd97f3d53ecf732'http://127.0.0.1:8000/account/logout/
退出(全部 token 失效)
Method and Url Structure
| Method |
Resource URL |
| POST |
/account/logout_all/ |
cURL Example
curl -X POST -H 'Authorization: Token fcfbbe8f594390a4c28ba4b3a5623c13f1261dd4'http://127.0.0.1:8000/account/logout_all/