[关闭]
@JackieQu 2018-04-19T08:18:27.000000Z 字数 2490 阅读 296

登录注册与用户信息

跟斌叔学编程


登录

Method and Url Structure

Method Resource URL
POST /server/userinfo/login_wx/

Request and Parameters

Name Description Required Default
code 微信参数 YES

Request

  1. {
  2. "code": "011Lcgsa1UB1IQ1Bztta1Gr8sa1Lcgsq"
  3. }

cURL Example

  1. curl -X POST -d data{...}
  2. http://127.0.0.1:8000/server/userinfo/login_wx/

JSON Response

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

注册

Method and Url Structure

Method Resource URL
POST /server/userinfo/signup_wx/

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": "136888582236",
  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/server/userinfo/signup_wx/

JSON Response

  1. {
  2. "token": "03d69f50b774f4fcf7139919d051965aea5a7d7b"
  3. }

查看个人信息

Method and Url Structure

Method Resource URL
GET /server/userinfo/whoami_wx

cURL Example

  1. curl -X GET -H 'Authorization: Token 68b76feaa3ec4f9da1ed7cfa6cd97f3d53ecf732'
  2. http://127.0.0.1:8000/server/userinfo/whoami_wx/

JSON Response

  1. {
  2. "pk": 1,
  3. "owner": "or6Un41fqh04N6ZU6qbgWbC2M8Eo",
  4. "is_pay": false,
  5. "nickname": "尼古拉斯·刘能",
  6. "avatar_url": "https://static1.bcjiaoyu.com/head7@3x.png",
  7. "group_info": {
  8. "status": 0,
  9. "status_display": "未组队未买课"
  10. },
  11. "sex": "N",
  12. "sex_display": "未知",
  13. "country": "呵呵国",
  14. "province": "哈哈省",
  15. "city": "嘿嘿市"
  16. }
  17. /*
  18. group_info = {"status": 0, "status_display": "未组队未买课"}
  19. group_info = {"status": 1, "status_display": "组队队员未满"}
  20. group_info = {"status": 2, "status_display": "组队已有资格"}
  21. group_info = {"status": 3, "status_display": "有钱任性买课"}
  22. */

绑定微信请求验证码

Method and Url Structure

Method Resource URL
GET /server/userinfo/bind_wx_request/

Request and Parameters

Name Description Required Default
username 手机号码 YES

Request

  1. {
  2. "username":"123456"
  3. }

cURL Example

  1. curl -X POST -d data{...}
  2. http://127.0.0.1:8000/server/userinfo/bind_wx_request/?username=123456

JSON Response

  1. {
  2. "message": "",
  3. "status": 0
  4. }

绑定微信(即注册到用户)

Method and Url Structure

Method Resource URL
POST /server/userinfo/bind_wx/

Request and Parameters

Name Description Required Default
username 电话号码 YES
password 密码 YES
verification_code 验证码 YES
userinfo 用户信息 YES

Request

  1. {
  2. "username":"18519791946",
  3. "password":"123456789",
  4. "verification_code":"916766",
  5. "userinfo":{
  6. "name":"Leon",
  7. "avatar":"https://static1.bcjiaoyu.com/head1@3x.png"
  8. }
  9. }

cURL Example

  1. // 这个注册需要微信中的 token
  2. curl -X POST -H 'Authorization: Token 68b76feaa3ec4f9da1ed7cfa6cd97f3d53ecf732' -d data{...}
  3. http://127.0.0.1:8000/server/userinfo/bind_wx/

JSON Response

  1. // 新用户
  2. {
  3. "message": "绑定注册成功"
  4. }
  5. // 网站注册过的用户
  6. {
  7. "message": "绑定成功"
  8. }
添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注