Skip to content

Instantly share code, notes, and snippets.

@Daltontastic
Created February 28, 2017 08:10
Show Gist options
  • Save Daltontastic/c55dffac411138ceea889b84c28eef1a to your computer and use it in GitHub Desktop.
Save Daltontastic/c55dffac411138ceea889b84c28eef1a to your computer and use it in GitHub Desktop.
<?php
function mcapi($address, $port)
{
$data = json_decode(file_get_contents("https://mcapi.ca/query/$address:$port/mcpe"), true);
if ($data["status"] === true) {
return $data;
} else {
return false;
}
}
$mcapi = mcapi("play.hnpe.us", "19132");
if ($mcapi !== false) {
$version = $mcapi["version"];
$software = $mcapi["software"];
$motd = $mcapi["motd"];
$playersOnline = $mcapi["players"]["online"];
$playersMax = $mcapi["players"]["max"];
echo "Version: $version, Software: $software, MOTD: $motd, Players Online: $playersOnline, Players Max: $playersMax";
} else {
echo "Server is offline or unreachable.";
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment