基于个人令牌的控制服务器
个人token 获取地址:https://f.upkk.com/home.php?mod=spacecp&ac=plugin&id=xnet_steam_openid:steam_settings
php
<?php
$url = 'https://f.upkk.com/plugin.php?id=srcds_server_user_manager:api_v1&module=L-app-restart';
$userid = 1; // 替换个人用户UID
$serverids = [12345, 12346, 12347]; // 替换服务器ID
$header_token = '12345'; // 替换您的个人token https://f.upkk.com/home.php?mod=spacecp&ac=plugin&id=xnet_steam_openid:steam_settings
// 设置请求头
$headers = array(
'Content-Type: application/x-www-form-urlencoded',
'X-Auth-Token: ' . $header_token
);
// 循环发送 POST 请求
foreach ($serverids as $serverid) {
// 构建 POST 请求数据
$data = array(
'userid' => $userid,
'serverid' => $serverid
);
// 发送 POST 请求
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
$status_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
// 获取响应内容
if ($status_code == 200) {
echo "Server ID {$serverid}: $response\n";
} else {
echo "Error for Server ID {$serverid}: $status_code\n";
}
}
?>
Python (重启多个服务器ID)
pip install tqdm
import requests
from tqdm import tqdm
url = 'https://f.upkk.com/plugin.php?id=srcds_server_user_manager:api_v1&module=L-app-restart'
userid = 1 # 替换个人用户UID
serverids = [12345, 12346, 12347] # 替换服务器ID
header_token = '12345' # 替换您的个人token https://f.upkk.com/home.php?mod=spacecp&ac=plugin&id=xnet_steam_openid:steam_settings
# 设置请求头
headers = {
'Content-Type': 'application/x-www-form-urlencoded',
'X-Auth-Token': header_token,
}
# 设置 tqdm 进度条
pbar = tqdm(serverids, desc='Processing Servers', unit='server')
# 循环发送 POST 请求
for serverid in pbar:
# 构建 POST 请求数据
data = {
'userid': userid,
'serverid': serverid,
}
# 发送 POST 请求
response = requests.post(url, data=data, headers=headers)
# 获取响应内容
if response.status_code == 200:
pbar.set_description(f"Server ID {serverid}: {response.text}")
else:
pbar.set_description(f"Error for Server ID {serverid}: {response.status_code}")
作者:admin 创建时间:2024-03-04 20:18
最后编辑:admin 更新时间:2024-09-25 02:22
最后编辑:admin 更新时间:2024-09-25 02:22