1. Go to this page and download the library: Download davidoc26/mojang-api library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
davidoc26 / mojang-api example snippets
use Davidoc26\MojangAPI\MojangAPI;
$mojangAPI = new MojangAPI();
$services = $mojangAPI->apiStatus();
foreach ($services as $service) {
echo $service->getName(); // the name of service
echo $service->getStatus(); // can be green/yellow/red
}
$uuid = $mojangAPI->getUuid('Test');
$users = $mojangAPI->getNameHistory($uuid);
foreach ($users as $user) {
echo $user->getName();
echo date('d M | Y', $user->getChangedToAt()); // Be careful! getChangedToAt() can return null
}
$url = $mojangAPI->getSkinUrl($uuid);
$head = $mojangAPI->renderHead($url, 300); // the second argument is the size of head
echo "<img src='$head' alt='head'>";
$user = $mojangAPI->authenticate('email','password');
$user->getName();
$user->getUuid();
$user->getAccessToken();
$user->nameAvailability($newName);
// You can also render the head of the current player.
$user->renderHead($size);