接入指南
欢迎使用我们的 API 系统。在开始接入前,请确保您已:
- 注册并登录账号(仅支持 QQ 邮箱注册)
- 在“密钥管理”中申请 API Key(需管理员审核)
- 获得审核通过后的 API Key 和 API Secret
1. V1 获取接口 (简化版)
正常仅需 API Key 即可快速获取账号,适合快速测试或低安全要求的内部调用。
请求地址: https://api.h5h8.top/api/v1/get-account
参数说明:
| 参数名 | 必填 | 说明 |
|---|---|---|
| api_key | 是 | 您的 API Key |
<?php
$apiKey = '您的API_KEY';
$url = "https://api.h5h8.top/api/v1/get-account?api_key=" . $apiKey;
$response = file_get_contents($url);
$result = json_decode($response, true);
if ($result['code'] === 200) {
echo "获取成功: " . $result['data']['account'];
} else {
echo "错误: " . $result['msg'];
}
?>
2. V2 获取接口 (标准版)
正常基于 HMAC-SHA256 签名,防止重放攻击,适合正式业务环境。
请求地址: https://api.h5h8.top/api/v2/get-account
签名计算: signature = HMAC-SHA256(api_secret, api_key + timestamp + nonce)
参数说明:
| 参数名 | 必填 | 说明 |
|---|---|---|
| api_key | 是 | 您的 API Key |
| timestamp | 是 | 当前 UNIX 时间戳 |
| nonce | 是 | 随机字符串 (32位) |
| signature | 是 | HMAC-SHA256 签名值 |
<?php
$apiKey = '您的API_KEY';
$apiSecret = '您的API_SECRET';
$timestamp = time();
$nonce = bin2hex(random_bytes(16));
// 计算签名
$signature = hash_hmac('sha256', $apiKey . $timestamp . $nonce, $apiSecret);
$url = "https://api.h5h8.top/api/v2/get-account";
$postData = [
'api_key' => $apiKey,
'timestamp' => $timestamp,
'nonce' => $nonce,
'signature' => $signature
];
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($postData));
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
$result = json_decode($response, true);
if ($result['code'] === 200) {
echo "获取成功: " . $result['data']['account'];
} else {
echo "失败: " . $result['msg'];
}
?>
错误代码说明
当 API 请求失败时,会返回相应的错误代码和信息。请根据下表进行排查:
| 状态码 (code) | 说明 (msg) | 解决建议 |
|---|---|---|
400 |
参数错误/缺失 | 检查请求参数名是否拼写正确,是否遗漏必填项。 |
401 |
身份验证失败 | 检查 API Key 是否正确,V2 接口请检查签名计算逻辑。 |
403 |
权限不足/密钥禁用 | 您的密钥可能已被管理员禁用或审核未通过,请前往后台查看状态。 |
404 |
库存不足 | 当前系统内没有可领取的账号,请联系管理员补充库存。 |
429 |
请求过于频繁 | 触发了 WAF 或接口限流,请降低调用频率。 |
500 |
服务器内部错误 | 系统处理异常,请联系技术人员。 |