不知道我应该如何放置标题,但这里是代码:
if(isset($stats->playerStatus->server->serverIPv6Address)){ // prefer the IPv6 address if it's there`
$srvDetails = file_get_contents('https://api.kag2d.com/server/ip/' . $stats->playerStatus->server->serverIPv6Address . '/port/' . $stats->playerStatus->server->serverPort . '/status');
}elseif(isset($stats->playerStatus->server->serverIPv4Address)){
$srvDetails = file_get_contents('https://api.kag2d.com/server/ip/' . $stats->playerStatus->server->serverIPv4Address . '/port/' . $stats->playerStatus->server->serverPort . '/status');
}
$srvContent = json_decode($srvDetails, true);
$srvName = $srvContent->serverName;
$playerString = 'Players: ' . $srvContent->currentPlayers . '/' . $srvContent->maxPlayers;
并且 $srvName 保持为空并且 $playerString 只是 Players: / 以https://api.kag2d.com/server/ip/199.168.184.8/port/23002/status为例谢谢