Created
February 28, 2017 08:10
-
-
Save Daltontastic/c55dffac411138ceea889b84c28eef1a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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