码桶
发现社区成员的开源项目
whois_proxy.php1.1 KB
<?php
// 允许跨域
header("Access-Control-Allow-Origin: *");
header("Access-Control-Allow-Headers: x-api-key, Content-Type");
header("Content-Type: application/json; charset=utf-8");
// 安全保存的 API Key
$apiKey = '这里换成你的 whois api key 我是用的 onefour https://yisi.yun。用他的可以直接要,免费给的';
$domain = isset($_GET['query']) ? trim($_GET['query']) : '';
if (empty($domain)) {
echo json_encode(['status' => false, 'error' => '请输入需要查询的域名']);
exit;
}
$targetUrl = 'https://yisi.yun/api/lookup?query=' . urlencode($domain);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $targetUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'x-api-key: ' . $apiKey,
'Content-Type: application/json'
]);
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if ($httpCode !== 200) {
echo json_encode(['status' => false, 'error' => '远端请求失败,状态码: ' . $httpCode]);
exit;
}
echo $response;