PHP code example of aberdeener / minecraft-oauth
1. Go to this page and download the library: Download aberdeener/minecraft-oauth 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/ */
aberdeener / minecraft-oauth example snippets
$client_id = '<Azure OAuth Client ID>';
$client_secret = '<Azure OAuth Client Secret>';
$redirect_uri = '<URL to this file>';
try {
$profile = (new \Aberdeener\MinecraftOauth\MinecraftOauth)->fetchProfile(
$client_id,
$client_secret,
$_GET['code'],
$redirect_uri,
);
} catch (\Aberdeener\MinecraftOauth\Exceptions\MinecraftOauthException $e) {
echo $e->getMessage();
}
echo 'Minecraft UUID: ' . $profile->uuid();
echo 'Minecraft Username: ' . $profile->username();
echo 'Minecraft Skin URL: ' . $profile->skins()[0]->url();
echo 'Minecraft Cape URL: ' . $profile->capes()[0]->url();