CCSWebsite/get_server_status.php
2025-07-04 23:49:18 +00:00

28 lines
645 B
PHP
Executable File

<?php
// get_server_status.php
// 设置服务器IP和端口
$serverIp = "9666.fun";
$serverPort = 23418;
// 构造API请求URL
$apiUrl = "https://forum.blmcpia.com/open-api/motdpe/api.php?ip=$serverIp&port=$serverPort";
// 使用cURL获取数据
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $apiUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
// 检查是否有错误
if ($response === false) {
http_response_code(500);
echo json_encode(["error" => "Failed to fetch server status"]);
exit;
}
// 返回JSON数据
header('Content-Type: application/json');
echo $response;
?>