API 接口文档

所有 API 请求通过 /api/v1.php 入口访问。

通用说明

请求格式

支持 GET / POST,Content-Type: application/json 或 application/x-www-form-urlencoded

通用参数

参数类型必填说明
app_idstring商户 AppID
timestampint当前时间戳(秒),5分钟有效
noncestring随机字符串(防重放)
signstringHMAC-SHA256 签名
datastringAES加密后的业务数据(JSON)

签名算法

  1. 收集所有请求参数(排除 sign 和 file)
  2. 按键名升序排列
  3. 拼接为 key1=value1&key2=value2 格式
  4. 使用 AppSecret 作为密钥,HMAC-SHA256 签名

加密方式

业务参数 JSON 使用 AES-256-CBC 加密,密钥为安装时生成的 crypt_key 的 SHA256 哈希。

1. 用户注册

action: register

参数类型必填说明
usernamestring用户名
passwordstring密码(明文,已通过AES加密传输)
emailstring邮箱

响应示例

{
    "status": 200,
    "message": "注册成功",
    "data": { "user_id": 1 },
    "time": 1700000000
}

2. 用户登录

action: login

参数类型必填说明
usernamestring用户名
passwordstring密码
device_codestring设备码(如启用设备绑定)
device_infostring设备信息

3. 卡密验证

action: verify_card

参数类型必填说明
card_keystring卡密
usernamestring绑定的用户名

4. 卡密使用(绑定到用户)

action: use_card

参数类型必填说明
card_keystring卡密
usernamestring要绑定的用户名

5. 设备绑定

action: bind_device

参数类型必填说明
usernamestring用户名
device_codestring设备码
device_infostring设备信息

6. 设备解绑

action: unbind_device

参数类型必填说明
usernamestring用户名
device_codestring设备码

7. IP授权验证

action: check_ip

参数类型必填说明
usernamestring用户名

系统自动获取客户端 IP 进行验证。

8. 用户信息查询

action: user_info

参数类型必填说明
usernamestring用户名

错误码

状态码说明
200成功
400参数错误
401未授权 / 签名验证失败
403禁止访问(IP未授权/设备未绑定等)
404资源不存在
429请求频率过高
500服务器错误