itecdn 5.x用户文档
itecdn 5.x / 用户 API

查询当前用户的消息订阅设置

GET/v1/messages/sub

查询当前登录用户的消息订阅记录。接口要求登录,不支持筛选参数;每条记录对应一个消息类型的邮件和短信接收开关。没有订阅记录时返回空数组。

身份认证

access-token

api-key + api-secret

认证定义
{
  "AccessToken": {
    "type": "apiKey",
    "in": "header",
    "name": "access-token",
    "description": "通过登录接口获得的短期访问令牌。"
  },
  "ApiKey": {
    "type": "apiKey",
    "in": "header",
    "name": "api-key",
    "description": "API Key;必须和 api-secret 同时发送。"
  },
  "ApiSecret": {
    "type": "apiKey",
    "in": "header",
    "name": "api-secret",
    "description": "API Secret;必须和 api-key 同时发送。"
  }
}

请求参数

未定义路径、查询或请求头参数。

响应

HTTP 200

成功与认证错误均返回 HTTP 200。成功时 data 为当前用户的 message_sub 表记录数组。

application/json

oneOf

oneOf · 1 · object
字段类型必填说明与约束
codeinteger必填

0 表示查询成功。

约束 / 默认值 / 示例
{
  "enum": [
    0
  ]
}
msgstring必填

成功提示。

约束 / 默认值 / 示例
{
  "enum": [
    "获取订阅成功"
  ]
}
dataarray <object>必填

当前用户的订阅记录;表中没有匹配记录时为空数组。

展开字段结构

当前用户的订阅记录;表中没有匹配记录时为空数组。

数组元素 · object
字段类型必填说明与约束
uidinteger必填

订阅所属用户 ID,固定为当前登录用户。

约束 / 默认值 / 示例
{
  "example": 12
}
msg_typestring必填

订阅的消息类型。

约束 / 默认值 / 示例
{
  "example": "announcement"
}
phoneinteger必填

短信订阅开关的数据库布尔值:1 开启,0 关闭;未设置时为空。

约束 / 默认值 / 示例
{
  "enum": [
    0,
    1
  ],
  "nullable": true
}
emailinteger必填

邮件订阅开关的数据库布尔值:1 开启,0 关闭;未设置时为空。

约束 / 默认值 / 示例
{
  "enum": [
    0,
    1
  ],
  "nullable": true
}
oneOf · 2 · object
字段类型必填说明与约束
codestring必填

未登录或登录会话无效时的业务错误码。

约束 / 默认值 / 示例
{
  "enum": [
    "login_required"
  ]
}
msgstring必填

认证失败原因。

datastring必填

业务错误时为空字符串。

约束 / 默认值 / 示例
{
  "enum": [
    ""
  ]
}
完整 Schema
{
  "oneOf": [
    {
      "type": "object",
      "required": [
        "code",
        "msg",
        "data"
      ],
      "properties": {
        "code": {
          "type": "integer",
          "enum": [
            0
          ],
          "description": "0 表示查询成功。"
        },
        "msg": {
          "type": "string",
          "enum": [
            "获取订阅成功"
          ],
          "description": "成功提示。"
        },
        "data": {
          "type": "array",
          "description": "当前用户的订阅记录;表中没有匹配记录时为空数组。",
          "items": {
            "type": "object",
            "required": [
              "uid",
              "msg_type",
              "phone",
              "email"
            ],
            "properties": {
              "uid": {
                "type": "integer",
                "description": "订阅所属用户 ID,固定为当前登录用户。",
                "example": 12
              },
              "msg_type": {
                "type": "string",
                "description": "订阅的消息类型。",
                "example": "announcement"
              },
              "phone": {
                "type": "integer",
                "enum": [
                  0,
                  1
                ],
                "nullable": true,
                "description": "短信订阅开关的数据库布尔值:1 开启,0 关闭;未设置时为空。"
              },
              "email": {
                "type": "integer",
                "enum": [
                  0,
                  1
                ],
                "nullable": true,
                "description": "邮件订阅开关的数据库布尔值:1 开启,0 关闭;未设置时为空。"
              }
            },
            "additionalProperties": false
          }
        }
      },
      "additionalProperties": false
    },
    {
      "type": "object",
      "required": [
        "code",
        "msg",
        "data"
      ],
      "properties": {
        "code": {
          "type": "string",
          "enum": [
            "login_required"
          ],
          "description": "未登录或登录会话无效时的业务错误码。"
        },
        "msg": {
          "type": "string",
          "description": "认证失败原因。"
        },
        "data": {
          "type": "string",
          "enum": [
            ""
          ],
          "description": "业务错误时为空字符串。"
        }
      },
      "additionalProperties": false
    }
  ]
}

示例

{
  "code": 0,
  "msg": "获取订阅成功",
  "data": [
    {
      "uid": 12,
      "msg_type": "announcement",
      "phone": 0,
      "email": 1
    }
  ]
}

查询成功

{
  "code": 0,
  "msg": "获取订阅成功",
  "data": [
    {
      "uid": 12,
      "msg_type": "announcement",
      "phone": 0,
      "email": 1
    }
  ]
}

没有订阅记录

{
  "code": 0,
  "msg": "获取订阅成功",
  "data": []
}

cURL 示例

根据文档生成;请替换主控地址、路径参数和凭证,并按上表补充查询参数。

curl --request GET \
  "https://master.example.invalid/v1/messages/sub" \
  --header "access-token: YOUR_ACCESS_TOKEN"

查看完整接口 JSON