Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function GetOnlinePlayers($ip, $port = 25565) {
- // Create a CURL connection to the API.
- $ch = curl_init('https://mcapi.us/server/status?ip='.$ip.'&port='.$port);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
- $results = curl_exec($ch);
- curl_close($ch);
- // Unserialize the JSON output
- $json = json_decode($results, true);
- // Return the online players
- $onlineplayers = $json['players']['now'];
- return $onlineplayers;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement