用户注册接口

  • 接口说明: 用户注册接口
  • 接口地址: /api/register
  • 请求方式: POST

请求参数

参数名称类型是否必须描述
usernamestring用户名
passwordstring密码
tokenstring微信公众号通过code参数换取token接口返回的 token
mobilestring手机号
register_reasonstring注册原因
codestring注册邀请码
js_codestring小程序用户名密码登录时传入,会绑定小程序用户信息。
微信小程序登陆code,https://developers.weixin.qq.com/miniprogram/dev/api/open-api/login/wx.login.html
ivstring小程序用户名密码登录时传入,会绑定小程序用户信息。
微信小程序用户数据数据加密算法的初始向量,https://developers.weixin.qq.com/miniprogram/dev/api/open-api/user-info/wx.getUserInfo.html
encryptedDatastring小程序用户名密码登录时传入,会绑定小程序用户信息。
微信小程序用户包括敏感数据在内的完整用户信息的加密数据,https://developers.weixin.qq.com/miniprogram/dev/api/open-api/user-info/wx.getUserInfo.html

请求示例

  1. {
  2. "data": {
  3. "type": "users",
  4. "attributes": {
  5. "username": "username",
  6. "password": "password",
  7. "register_reason": "这是一条注册原因"
  8. }
  9. }
  10. }

返回说明

  • 注册成功, http 状态码: 200
  • 注册失败, http 状态码: 422
  • 注册失败, http 状态码: 401 详见- 语言包说明

返回结果

参数名称类型出现要求描述
dataobject基础数据
typestring数据类型
idint数据 id
attributesobject数据属性
attributes.usernamestring用户名
attributes.nicknamestring昵称
attributes.mobilestring手机号
attributes.unionIdstringunion_id
attributes.lastLoginIpstring最后登陆 IP
attributes.createdAtdatetime创建时间
attributes.updatedAtdatetime修改时间

返回示例

成功示例:

  1. {
  2. "data": {
  3. "type": "token",
  4. "id": "1",
  5. "attributes": {
  6. "token_type": "Bearer",
  7. "expires_in": 2592000,
  8. "access_token": "eyJ0eXAiOiJKV1Q......P16l7srpANq3OzQkcjQrPO1nRKtUDGkYREEnGR-5fpw",
  9. "refresh_token": "def502005261a2......d861786ce8acc411ca83a0286526db35e67c937b607"
  10. }
  11. }
  12. }

失败示例:

  1. {
  2. "errors": [
  3. {
  4. "status": "422",
  5. "code": "validation_error",
  6. "detail": ["用户名 已经存在。"],
  7. "source": {
  8. "pointer": "/data/attributes/username"
  9. }
  10. }
  11. ]
  12. }