Need help with a live minecraft server status checker.

Ask about a PHP problem here.
Post Reply
mewcrafted
Posts: 2
Joined: Mon Jan 27, 2014 6:56 am

Need help with a live minecraft server status checker.

Post 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.
$status = json_decode( file_get_contents('http://api.iamphoenix.me/status/?server ... clean=true'), true);

$playercount  = json_decode( file_get_contents('http://api.iamphoenix.me/players/?serve ... 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';

}
User avatar
Temor
Posts: 1186
Joined: Thu May 05, 2011 8:04 pm

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

Post 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.
mewcrafted
Posts: 2
Joined: Mon Jan 27, 2014 6:56 am

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

Post by mewcrafted »

Thanks, I took your suggestion for using ajax and it now refreshes with time I set it at.
Post Reply