所以这就是我到目前为止所做的,但由于某些原因它无法正常工作
<?PHP
require MCQuery . '/MinecraftQuery.class.php';
try
{
$Query->Connect( '$_GET['ip'];', $_GET['port'] );
}
catch( MinecraftQueryException $e )
{
echo $e->getMessage( );
}
if(($Players = $Query->GetPlayers()) !== false) {
foreach($Players as $Player) {
echo "<a href='#' class='hint--bottom' data-hint=".$Player." ><img src=https://minotar.net/avatar/".$Player."/50.png Title=".$Player."></a>
";
}
}
?>
提前致谢:)
答案 0 :(得分:0)
这个怎么样,你的代码中有语法错误
$Query->Connect( $_GET['ip'], $_GET['port'] );
而不是
$Query->Connect( '$_GET['ip'];', $_GET['port'] );
答案 1 :(得分:0)
这是我对我的Minecraft服务器的查询。它在我的服务器上工作,我在同一目录中有MinecraftQuery.class.php,所以一定要从那里运行它。
<?php
require __DIR__ . '/MinecraftQuery.class.php';
$Query = new MinecraftQuery( );
try
{
$Query->Connect( '192.99.0.12', 25565 );
foreach ($Query->GetPlayers() as $arrayItem)
{
echo "<a href='statistics/index.php?page=player&name=" . $arrayItem . "'><img class='tooltip' style='border-radius:5;padding-top:2px'title='" . $arrayItem . "' src='https://minotar.net/avatar/" . $arrayItem ."/40'></a> " ;
}
}
catch( MinecraftQueryException $e )
{
echo $e->getMessage( );
}
?>