Need help with a live minecraft server status checker.
Posted: Mon Jan 27, 2014 7:02 am
I am trying to make a minecraft server status checker using a pre-built api.
Link here http://api.iamphoenix.me/index.php
This is showing the players and whether the server is online or offline.
I would like to learn how to make it auto-refresh every 5 minutes or when a player joins the server.
[syntax=php]$status = json_decode( file_get_contents('http://api.iamphoenix.me/status/?server_ip=IPGOESHERE:PORT&clean=true'), true);
$playercount = json_decode( file_get_contents('http://api.iamphoenix.me/players/?server_ip=IPGOESHERE:PORT&clean=true'), true);
if($status['status'] == 'true') {
// Use any command in here you like to execute if the server is online, echo "something" would print out 'something'
echo 'Prison: Online';
echo '<br>';
echo 'Players: ' . $playercount['players'] . '/' . $playercount['players_max'];
} else {
// Same thing here, however this is for when the server is offline.
echo 'Prison: Offline';
}[/syntax]
Link here http://api.iamphoenix.me/index.php
This is showing the players and whether the server is online or offline.
I would like to learn how to make it auto-refresh every 5 minutes or when a player joins the server.
[syntax=php]$status = json_decode( file_get_contents('http://api.iamphoenix.me/status/?server_ip=IPGOESHERE:PORT&clean=true'), true);
$playercount = json_decode( file_get_contents('http://api.iamphoenix.me/players/?server_ip=IPGOESHERE:PORT&clean=true'), true);
if($status['status'] == 'true') {
// Use any command in here you like to execute if the server is online, echo "something" would print out 'something'
echo 'Prison: Online';
echo '<br>';
echo 'Players: ' . $playercount['players'] . '/' . $playercount['players_max'];
} else {
// Same thing here, however this is for when the server is offline.
echo 'Prison: Offline';
}[/syntax]