help with catching avatars

Hello i need help with a script :smiley:

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 2 /*Custom CSS Overrides*/ body { font-family: 'Lato', sans-serif !important; }

MC PHP Query


General Information

<?php if ($serverdata["status"] == "200" && $data_general['error'] == "") { ?> <?php } ?> <?php if ($serverdata["status"] == "200" && $data_general['error'] == "") { ?> <?php } ?> <?php if ($serverdata["status"] == "200" && $data_general['error'] == "") { ?> <?php } ?>
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 .= " ";} //Display the avatars only when there are players online. if($data_general['player']['online'] > 0) { print_r($users); } //If no avatars can be shown, display an error. else { echo "
There are no players online at the moment!
"; } }else{ echo "
Query must be enabled in your server.properties file!
"; } ?>
[/php]

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? :smiley:

The New Api : http://mcapi.sweetcode.de/index.php#start

Thx for all Helps :smiley:

Well, server IP 134.255.235.31 seems to be a dead IP. It does not display anything.

And, you are using an API from “mcapi.sweetcode.de/api/v2/” and that seems to be coded wrong, too.

So, I do not think it is the rest of your code, just the IP and the API.
It appears that you are calling the API incorrectly. You can call it using /api/?favicon&ip= with the IP
to get the favicon of that IP. And, similar for the player info. I did not see how to do it with the get_data
version as you have it. Perhaps you just need to add in the other two flags, ?favicon and ?player…

See mcapi.sweetcode.de for more info…

Sponsor our Newsletter | Privacy Policy | Terms of Service