API文档
授权系统API接口使用说明
域名/IP授权验证API
接口地址:
https://17.0ld.cn/api/validate.php
请求方式:
GET POST JSON请求参数:
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
auth_key |
string | 是 | 授权密钥 |
domain_or_ip |
string | 是 | 要验证的域名或IP地址 |
请求示例:
GET请求:
https://17.0ld.cn/api/validate.php?auth_key=YOUR_AUTH_KEY&domain_or_ip=example.com
POST请求(表单):
POST https://17.0ld.cn/api/validate.php
Content-Type: application/x-www-form-urlencoded
auth_key=YOUR_AUTH_KEY&domain_or_ip=example.com
POST请求(JSON):
POST https://17.0ld.cn/api/validate.php
Content-Type: application/json
{
"auth_key": "YOUR_AUTH_KEY",
"domain_or_ip": "example.com"
}
返回示例:
验证成功:
{
"valid": true,
"message": "授权验证通过",
"user_info": {
// 用户信息
}
}
验证失败:
{
"valid": false,
"message": "授权密钥不存在"
}
客户端集成示例
<?php
$authKey = 'YOUR_AUTH_KEY';
$domain = $_SERVER['HTTP_HOST']; // 当前域名
$url = 'https://17.0ld.cn/api/validate.php';
$params = http_build_query([
'auth_key' => $authKey,
'domain_or_ip' => $domain
]);
$response = file_get_contents($url . '?' . $params);
$result = json_decode($response, true);
if ($result['valid']) {
echo "授权验证通过";
// 继续执行受保护的代码
} else {
echo "授权验证失败: " . $result['message'];
exit;
}
?>
async function validateAuth() {
const authKey = 'YOUR_AUTH_KEY';
const domainOrIp = window.location.hostname;
try {
const response = await fetch('https://17.0ld.cn/api/validate.php', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
auth_key: authKey,
domain_or_ip: domainOrIp
})
});
const result = await response.json();
if (result.valid) {
console.log('授权验证通过');
} else {
console.log('授权验证失败:', result.message);
}
} catch (error) {
console.error('请求失败:', error);
}
}
validateAuth();
curl -X POST "https://17.0ld.cn/api/validate.php" \
-H "Content-Type: application/json" \
-d '{"auth_key": "YOUR_AUTH_KEY", "domain_or_ip": "example.com"}'
错误码说明
| 错误码 | 说明 | 解决方案 |
|---|---|---|
INVALID_KEY |
授权密钥不存在或无效 | 检查授权密钥是否正确 |
KEY_EXPIRED |
授权密钥已过期 | 续费或重新购买授权 |
DOMAIN_NOT_ALLOWED |
域名未在授权范围内 | 检查域名绑定设置 |
IP_NOT_ALLOWED |
IP地址未在授权范围内 | 检查IP绑定设置 |
KEY_SUSPENDED |
授权密钥已被暂停 | 联系管理员处理 |