开发文档中心

全面的API接口文档和SDK开发指南,帮助您快速接入授权验证系统

概述介绍

本系统提供标准的 RESTful API 接口,支持卡密验证、激活、域名授权、设备绑定等核心功能。所有接口均返回 JSON 格式数据,支持 GET 和 POST 请求方式。

99.9%
接口可用性
<50ms
平均响应时间
HTTPS
安全传输

快速接入

必填参数(登录管理后台获取)

product_id 产品ID,在【产品管理】列表中查看(数字,如: 1, 2, 3)
secret_key 产品密钥,在【产品管理 → 编辑 → 产品密钥】中查看(48位字符串),用于API签名验证
encrypt_key 加密密钥,在【产品管理 → 编辑 → 加密密钥】中查看(32位字符串),用于加密本地缓存

详细说明和更多参数请登录管理后台查看【帮助中心】

1

获取产品ID和密钥

登录管理后台,在【产品管理】中获取产品ID、产品密钥和加密密钥

2

下载SDK并配置

从管理后台【帮助中心】下载对应语言的SDK,填写产品ID和密钥

3

调用验证接口

使用SDK提供的方法进行用户验证、卡密激活等操作

API 接口参考

POST /api/verify.php

验证用户卡密是否有效,检查到期时间和设备绑定状态。

请求参数

参数名 类型 必填 说明
product_idint产品ID
usernamestring用户名
device_idstring设备唯一标识

响应示例

{
    "success": true,
    "message": "验证成功",
    "data": {
        "username": "test_user",
        "expire_time": 1735689600,
        "device_count": 1,
        "max_devices": 3,
        "status": "active"
    }
}
POST /api/activate.php

使用卡密激活用户账号,延长使用时间。

请求参数

参数名 类型 必填 说明
product_idint产品ID
usernamestring用户名
card_keystring卡密
device_idstring设备唯一标识

响应示例

{
    "success": true,
    "message": "激活成功",
    "data": {
        "username": "test_user",
        "expire_time": 1767225600,
        "added_days": 30
    }
}
GET /api/domain-verify.php

验证域名是否已授权。

请求参数

参数名 类型 必填 说明
domainstring域名
product_idint产品ID

响应示例

{
    "success": true,
    "message": "域名已授权",
    "data": {
        "domain": "example.com",
        "expire_time": 1735689600,
        "status": "active"
    }
}
POST /api/unbind.php

解绑用户绑定的设备。

请求参数

参数名 类型 必填 说明
product_idint产品ID
usernamestring用户名
device_idstring设备ID,不传则解绑所有设备
POST /api/machines.php?action=verify

机器码授权验证,支持域名+机器码双重绑定。

请求参数

参数名 类型 必填 说明
product_idint产品ID
machine_codestring机器码
domainstring授权域名

响应示例

{
    "success": true,
    "message": "授权验证通过",
    "data": {
        "machine_code": "xxx",
        "expire_time": 1735689600,
        "status": "active",
        "auth_type": "bind"
    }
}
POST /api/offline-certs.php?action=verify

离线授权证书验证,无需联网也能验证授权。

请求参数

参数名 类型 必填 说明
cert_codestring证书代码
machine_codestring机器码

响应示例

{
    "success": true,
    "message": "证书验证通过",
    "data": {
        "expire_time": 1735689600,
        "is_valid": true
    }
}
GET /api/versions.php?action=check

检测新版本,支持增量更新。

请求参数

参数名 类型 必填 说明
product_idint产品ID
versionstring当前版本号
machine_codestring机器码

响应示例

{
    "success": true,
    "data": {
        "has_update": true,
        "latest_version": "2.0.0",
        "update_type": "force",
        "changelog": "新功能更新...",
        "download_url": "/api/versions.php?action=download&id=1"
    }
}
POST /api/heartbeat.php

客户端心跳检测,上报在线状态。

请求参数

参数名 类型 必填 说明
product_idint产品ID
machine_codestring机器码
domainstring域名

响应示例

{
    "success": true,
    "data": {
        "interval": 3600,
        "status": "active"
    }
}
GET /api/query.php

查询用户授权信息。

请求参数

参数名 类型 必填 说明
product_idint产品ID
usernamestring用户名

SDK 开发指南

PHP SDK

适用于PHP 7.0+

安装

require_once 'sdk/LicenseClient.php';

使用示例

// 必填参数:server_url, product_id, secret_key, encrypt_key
$client = new LicenseClient(
    'https://your-domain.com',  // 当前站点域名
    1,                          // 产品ID
    'your_secret_key_48chars',  // 产品密钥(48位)
    'your_encrypt_key_32chars'  // 加密密钥(32位)
);

// 验证用户
$result = $client->verify('username', 'device_id');
if ($result['success']) {
    echo "验证成功,到期时间:" . date('Y-m-d', $result['data']['expire_time']);
}

详细使用说明请登录管理后台查看【帮助中心】

Python SDK

适用于Python 3.6+

使用示例

from license_client import LicenseClient

# 必填参数:server_url, product_id, secret_key, encrypt_key
client = LicenseClient(
    server_url='https://your-domain.com',  # 当前站点域名
    product_id=1,                          # 产品ID
    secret_key='your_secret_key_48chars',  # 产品密钥(48位)
    encrypt_key='your_encrypt_key_32chars' # 加密密钥(32位)
)

# 验证用户
result = client.verify('username', 'device_id')
if result['success']:
    print(f"验证成功,到期时间: {result['data']['expire_time']}")

详细使用说明请登录管理后台查看【帮助中心】

Node.js SDK

适用于Node.js 12+

使用示例

const { LicenseClient } = require('./sdk/license_client');

// 必填参数:serverUrl, productId, secretKey, encryptKey
const client = new LicenseClient({
    serverUrl: 'https://your-domain.com',  // 当前站点域名
    productId: 1,                          // 产品ID
    secretKey: 'your_secret_key_48chars',  // 产品密钥(48位)
    encryptKey: 'your_encrypt_key_32chars' // 加密密钥(32位)
});

// 验证用户
const result = await client.verify('username', 'device_id');
if (result.success) {
    console.log('验证成功', result.data);
}

详细使用说明请登录管理后台查看【帮助中心】

错误码说明

错误码 说明
1001参数错误
1002产品不存在
1003用户不存在
1004卡密无效
1005卡密已使用
1006卡密已过期
2001用户已过期
2002设备数量超限
2003设备未绑定
3001域名未授权

常见问题

如何获取设备唯一标识?
设备唯一标识可以是硬件ID、MAC地址、CPU序列号等。建议使用组合方式生成,如:MD5(CPU_ID + 主板序列号 + 硬盘序列号)。
设备数量超限怎么办?
可以在管理后台解绑旧设备,或者使用解绑接口自行解绑。也可以升级产品套餐增加可绑定设备数量。
如何实现域名授权?
在您的Web应用中调用域名授权接口,传入当前域名和产品ID。系统会返回域名是否已授权及有效期。
接口返回超时怎么办?
请检查网络连接,确保服务器可以访问API地址。建议设置合理的超时时间(如5秒),并实现重试机制。

© 2024 软件授权验证系统. 技术支持:support@example.com