[关闭]
@JackieQu 2018-06-12T09:07:10.000000Z 字数 2202 阅读 361

登录注册与用户信息

好热闹TeaShop


登录

Method and Url Structure

Method Resource URL
POST /account/login/

Request and Parameters

Name Description Required Default
code 微信参数 YES

Request

  1. {
  2. "code":"1234"
  3. }

cURL Example

  1. curl -X POST -d data{...}
  2. http://127.0.0.1:8000/account/login/

JSON Response

  1. {
  2. "session": 602501615210
  3. }
  4. // 注册后回登录会返回 token 信息
  5. {
  6. "token": "fcfbbe8f594390a4c28ba4b3a5623c13f1261dd4",
  7. "session": 514719800189
  8. }

注册

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

  1. {
  2. "session": "602501615210",
  3. "nickname": "昵称",
  4. "avatar_url": "https://static1.bcjiaoyu.com/head7@3x.png",
  5. "country": "呵呵国",
  6. "province": "哈哈省",
  7. "city": "嘿嘿市"
  8. }

cURL Example

  1. curl -X POST -d data{...}
  2. http://127.0.0.1:8000/account/signup/

JSON Response

  1. {
  2. "token": "68b76feaa3ec4f9da1ed7cfa6cd97f3d53ecf732"
  3. }

查看个人信息

Method and Url Structure

Method Resource URL
GET /account/whoami

cURL Example

  1. curl -X GET -H 'Authorization: Token 68b76feaa3ec4f9da1ed7cfa6cd97f3d53ecf732'
  2. http://127.0.0.1:8000/account/whoami

JSON Response

  1. {
  2. "pk": 2,
  3. "owner": "opSbp2JARhmzgmez9yObTt9aSybs2",
  4. "nickname": "昵称",
  5. "avatar_url": "https://static1.bcjiaoyu.com/head7@3x.png",
  6. "sex": "N",
  7. "sex_display": "未知",
  8. "country": "呵呵国",
  9. "province": "哈哈省",
  10. "city": "嘿嘿市"
  11. }

查看他人信息

Method and Url Structure

Method Resource URL
GET /account/profile/&{owner}

Request and Parameters

Name Description Required Default
owner owner YES

Request

  1. opSbp1JARhmzgmez9yObTt9aSybs1

cURL Example

  1. curl -X PUT/PATCH -H 'Authorization: Token 68b76feaa3ec4f9da1ed7cfa6cd97f3d53ecf732' -d data{...}
  2. http://127.0.0.1:8000/account/profile/opSbp1JARhmzgmez9yObTt9aSybs1/

JSON Response

  1. {
  2. "pk": 1,
  3. "owner": "opSbp1JARhmzgmez9yObTt9aSybs1",
  4. "nickname": "你瞅啥",
  5. "avatar_url": "http://p3.gexing.com/G1/M00/DF/94/rBACFFIuWbCQ5SKSAAAcnnJofuI009_200x200_3.jpg",
  6. "sex": "N",
  7. "sex_display": "未知",
  8. "country": "嘿嘿国",
  9. "province": "哈哈省",
  10. "city": "呵呵市"
  11. }

退出(当前 token 失效)

Method and Url Structure

Method Resource URL
POST /account/logout/

cURL Example

  1. curl -X POST -H 'Authorization: Token 68b76feaa3ec4f9da1ed7cfa6cd97f3d53ecf732'
  2. http://127.0.0.1:8000/account/logout/

退出(全部 token 失效)

Method and Url Structure

Method Resource URL
POST /account/logout_all/

cURL Example

  1. curl -X POST -H 'Authorization: Token fcfbbe8f594390a4c28ba4b3a5623c13f1261dd4'
  2. http://127.0.0.1:8000/account/logout_all/
添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注