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]
Need help with a live minecraft server status checker.
-
- Posts: 2
- Joined: Mon Jan 27, 2014 6:56 am
Re: Need help with a live minecraft server status checker.
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.
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.
-
- Posts: 2
- Joined: Mon Jan 27, 2014 6:56 am
Re: Need help with a live minecraft server status checker.
Thanks, I took your suggestion for using ajax and it now refreshes with time I set it at.