所有 API 请求都需要在 HTTP 头部包含以下认证信息:
X-App-Id: 你的应用ID
X-Api-Key: 你的API密钥
这些信息可以在应用详情页面找到。
验证许可证是否有效,并将设备与许可证绑定。
licenceKey - 许可证密钥
deviceId - 设备唯一标识符
POST /licences/api/validate
Content-Type: application/json
X-App-Id: app_abc123
X-Api-Key: key_xyz789
{
"licenceKey": "LIC-ABCDEF-123456-XYZ",
"deviceId": "device_12345"
}
{
"valid": true,
"message": "许可证验证成功",
"licenceId": "60f8a5d3e13823687d3e9c24",
"issuedTo": "公司名称",
"expiryDate": "2026-08-24T00:00:00.000Z",
"features": ["feature1", "feature2"]
}
{
"valid": false,
"reason": "licence_expired",
"message": "许可证已过期"
}
licence_not_found - 许可证不存在licence_expired - 许可证已过期licence_revoked - 许可证已被撤销max_devices_reached - 已达到最大设备数量限制server_error - 服务器内部错误async function validateLicence(licenceKey, deviceId) {
try {
const response = await fetch('https://your-server.com/licences/api/validate', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-App-Id': 'your_app_id',
'X-Api-Key': 'your_api_key'
},
body: JSON.stringify({ licenceKey, deviceId })
});
const result = await response.json();
return result;
} catch (error) {
console.error('验证许可证时出错:', error);
return { valid: false, reason: 'network_error' };
}
}
import requests
def validate_licence(licence_key, device_id):
try:
response = requests.post(
'https://your-server.com/licences/api/validate',
headers={
'Content-Type': 'application/json',
'X-App-Id': 'your_app_id',
'X-Api-Key': 'your_api_key'
},
json={
'licenceKey': licence_key,
'deviceId': device_id
}
)
return response.json()
except Exception as e:
print(f"验证许可证时出错: {e}")
return {'valid': False, 'reason': 'network_error'}