概述
极简卡密验证系统提供RESTful API接口,用于验证卡密、心跳检测和解绑机器码等功能。所有API接口均使用HTTP POST方法,返回JSON格式的数据。
基本信息
系统地址:
https://cardverify.geticp.cn
- 接口地址:
https://cardverify.geticp.cn/api/ - 数据格式: JSON
- 字符编码: UTF-8
- HTTP方法: POST
请求头
Content-Type: application/x-www-form-urlencoded
认证说明
API接口不需要传统的身份验证,但会通过以下方式进行安全检查:
- IP访问限制: 系统会记录每个IP的访问频率,防止暴力破解
- 机器码绑定: 卡密验证后会绑定到特定机器码,确保一卡一机
- 心跳检测: 定期发送心跳请求以维持卡密状态
- 时间戳验证: 部分接口可能需要时间戳参数防止重放攻击
机器码获取
机器码是客户端设备的唯一标识,可以使用以下方式之一生成:
- CPU序列号 + 主板序列号
- 硬盘序列号 + MAC地址
- 系统GUID + 用户名
建议使用加密算法对机器码进行哈希处理,确保唯一性和安全性。
卡密验证
接口说明
验证卡密的有效性,如果验证成功则绑定到当前机器码并返回相关信息。
请求信息
POST /api/verify.php
请求参数
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| card_key | string | 是 | 要验证的卡密 |
| bound_machine_code | string | 是 | 客户端机器码 |
| program_type_id | int | 否 | 程序类型ID,用于区分不同程序 |
响应示例
成功响应
{
"success": true,
"message": "验证成功",
"data": {
"card_id": 123,
"card_key": "ABCD-1234-EFGH-5678",
"program_type_id": "测试程序",
"category_id": "月卡",
"expire_at": "2023-12-31 23:59:59",
"bind_time": "2023-11-01 10:30:45",
"login_count": 1,
"rebind_count": 3,
"max_rebind_count": 3,
"is_permanent": false,
"days_remaining": 30
}
}
失败响应
{
"success": false,
"message": "卡密无效或已过期",
"error_code": 1001}
心跳检测
接口说明
定期发送心跳请求以维持卡密状态,更新最后在线时间,检查卡密是否仍然有效。
请求信息
POST /api/heartbeat.php
请求参数
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| card_key | string | 是 | 已验证的卡密 |
| bound_machine_code | string | 是 | 客户端机器码(必须与验证时一致) |
响应示例
成功响应
{
"success": true,
"message": "心跳成功",
"data": {
"card_id": 123,
"expire_at": "2023-12-31 23:59:59",
"last_heartbeat": "2023-11-01 11:30:45",
"days_remaining": 30,
"is_permanent": false
}
}
失败响应
{
"success": false,
"message": "卡密已过期",
"error_code": 1002}
解绑机器码
接口说明
解绑当前机器码,允许卡密在其他设备上使用。每个卡密有有限的解绑次数。
请求信息
POST /api/unbind.php
请求参数
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| card_key | string | 是 | 要解绑的卡密 |
| bound_machine_code | string | 是 | 当前绑定的机器码 |
| unbind_reason | string | 否 | 解绑原因 |
响应示例
成功响应
{
"success": true,
"message": "解绑成功",
"data": {
"card_id": 123,
"max_rebind_count": 2,
"unbind_time": "2023-11-01 12:30:45"
}
}
失败响应
{
"success": false,
"message": "解绑次数已用完",
"error_code": 1003}
响应格式
通用响应格式
所有API接口都遵循统一的响应格式:
{
"success": boolean,
"message": "string",
"data": object,
"error_code": int
}
字段说明
| 字段名 | 类型 | 说明 |
|---|---|---|
| success | boolean | 请求是否成功 |
| message | string | 响应消息 |
| data | object | 响应数据,成功时包含相关信息 |
| error_code | int | 错误代码,失败时返回 |
错误代码
| 错误代码 | 说明 |
|---|---|
| 1001 | 卡密无效或已过期 |
| 1002 | 卡密已过期 |
| 1003 | 解绑次数已用完 |
| 1004 | 卡密已被封禁 |
| 1005 | 卡密已绑定到其他设备 |
| 1006 | 机器码不匹配 |
| 2001 | 请求参数不完整 |
| 3001 | IP访问频率过高 |
| 3002 | IP已被封禁 |
| 4001 | 服务器内部错误 |
| 4002 | 数据库连接错误 |
| 其他 | 均为失败(未处理异常) |
代码示例
PHP示例
<?php
// 卡密验证示例
function verifyCardKey($cardKey, $machineCode) {
$apiUrl = '系统地址/api/verify.php';
$postData = [
'card_key' => $cardKey,
'bound_machine_code' => $machineCode,
'program_type_id' => 1
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $apiUrl);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($postData));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if ($httpCode != 200) {
return ['success' => false, 'message' => 'API请求失败'];
}
$result = json_decode($response, true);
return $result;
}
// 使用示例
$cardKey = 'ABCD-1234-EFGH-5678';
$machineCode = generateMachineCode(); // 自定义函数生成机器码
$result = verifyCardKey($cardKey, $machineCode);
if ($result['success']) {
echo "验证成功!到期时间: " . $result['data']['expire_at'];
} else {
echo "验证失败: " . $result['message'];
}
?>
Python示例
import requests
import hashlib
import platform
import uuid
def generate_machine_code():
"""生成机器码"""
machine_info = f"{platform.node()}-{platform.processor()}-{uuid.getnode()}"
return hashlib.md5(machine_info.encode()).hexdigest()
def verify_card_key(card_key, machine_code):
"""验证卡密"""
api_url = '系统地址/api/verify.php'
data = {
'card_key': card_key,
'bound_machine_code': machine_code,
'program_type_id': 1
}
try:
response = requests.post(api_url, data=data, timeout=30)
result = response.json()
return result
except Exception as e:
return {'success': False, 'message': f'请求异常: {str(e)}'}
# 使用示例
card_key = 'ABCD-1234-EFGH-5678'
machine_code = generate_machine_code()
result = verify_card_key(card_key, machine_code)
if result['success']:
print(f"验证成功!到期时间: {result['data']['expire_at']}")
else:
print(f"验证失败: {result['message']}")
C#示例
using System;
using System.Net;
using System.Text;
using System.Security.Cryptography;
using System.Management;
public class CardKeyVerifier
{
public static string GenerateMachineCode()
{
// 获取CPU序列号
string cpuId = "";
using (ManagementObjectSearcher searcher = new ManagementObjectSearcher("select * from Win32_Processor"))
{
foreach (ManagementObject obj in searcher.Get())
{
cpuId = obj["ProcessorId"].ToString();
break;
}
}
// 获取主板序列号
string boardId = "";
using (ManagementObjectSearcher searcher = new ManagementObjectSearcher("select * from Win32_BaseBoard"))
{
foreach (ManagementObject obj in searcher.Get())
{
boardId = obj["SerialNumber"].ToString();
break;
}
}
// 组合并生成MD5
string machineInfo = $"{cpuId}-{boardId}";
using (MD5 md5 = MD5.Create())
{
byte[] hashBytes = md5.ComputeHash(Encoding.UTF8.GetBytes(machineInfo));
StringBuilder sb = new StringBuilder();
for (int i = 0; i < hashBytes.Length; i++)
{
sb.Append(hashBytes[i].ToString("x2"));
}
return sb.ToString();
}
}
public static string VerifyCardKey(string cardKey, string machineCode)
{
string apiUrl = "系统地址/api/verify.php";
using (WebClient client = new WebClient())
{
client.Headers.Add("Content-Type", "application/x-www-form-urlencoded");
string postData = $"card_key={cardKey}&bound_machine_code={machineCode}&program_type_id=1";
try
{
string response = client.UploadString(apiUrl, "POST", postData);
return response;
}
catch (Exception ex)
{
return $"{{\"success\": false, \"message\": \"请求异常: {ex.Message}\"}}";
}
}
}
// 使用示例
public static void Main(string[] args)
{
string cardKey = "ABCD-1234-EFGH-5678";
string machineCode = GenerateMachineCode();
string result = VerifyCardKey(cardKey, machineCode);
Console.WriteLine(result);
}
}