Page 1 of 1

Need help with a live minecraft server status checker.

Posted: Mon Jan 27, 2014 7:02 am
by mewcrafted
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]

Re: Need help with a live minecraft server status checker.

Posted: Mon Jan 27, 2014 7:40 pm
by Temor
You have many ways of auto refreshing.
You can:
Auto refresh using ajax / javascript. This is essentially the same as pressing F5 every few minutes.
Run a Cron Job.

However, making it update when someone joins requires push notifications, and that's not something I can easily explain.

Re: Need help with a live minecraft server status checker.

Posted: Tue Jan 28, 2014 12:15 am
by mewcrafted
Thanks, I took your suggestion for using ajax and it now refreshes with time I set it at.