Hello i need help with a script
This is the Script:
[php]<?php
//The following script is tested only with servers running on Minecraft 1.7.
$SERVER_IP=“134.255.235.31”; //Insert the IP of the server you want to query. Query must be enabled in your server.properties file!
//You can either insert the DNS (eg. play.hivemc.com) OR the IP itself (eg. 187.23.123.21).
//Note: port is not neccesary when running the server on default port, otherwise use it!
// Get Data and Status API Checker
function get_data($url)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 5);
$data = curl_exec($ch);
$httpStatus = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
return array(
‘status’ => $httpStatus,
‘data’ => $data
);
}
//Query the data from the server using Minecraft API (also known as IamPhoenix’s API)
$userlistserver = get_data(“http://mcapi.sweetcode.de/api/v2/?ip=” . $SERVER_IP . “”);
$serverdata = get_data(“http://mcapi.sweetcode.de/api/v2/?info&ip=” . $SERVER_IP . “”);
// Json Decode
$data_list = json_decode($userlistserver[“data”], true);
$data_general = json_decode($serverdata[“data”], true);
//Put the collected player information into an array for later use.
$array_list = explode(’,’, $data_list[‘players’]);
?>
MC PHP Query
General Information
IP | <?php echo $SERVER_IP; ?> |
Version | <?php echo $data_general['version']; ?> |
Players | <?php echo "".$data_general['player']['online']." / ".$data_general['player']['max']."";?> |
Status | <? if($data_general['status'] == 'true') { echo " Server is online"; } else { echo " Server is offline";}?> |
Latency | <?php echo "".$data_general['ping']."ms"; ?> |
Players
<?php if ($userlistserver["status"] == "200" && $data_general['error'] == "") { //Take the username values from the array & grab the avatars from Minotar. foreach($array_list as $key => $value){$users .= "Soo this is an Minecraft Query Script, it catch server info and minecraft avatars+names, the old api site is down so now i found a new api but i cant make it so that the avatars+names are displayed…
Can anybody help me?
The New Api : http://mcapi.sweetcode.de/index.php#start
Thx for all Helps