A little while back i decided i would like to make sure that any user signing up for my server website would in fact be a real Minecraft player with a valid username.
I wrote a small script to do just that, it receives a username and checks the username against Minecraft.net's list of premium usernames.
Hope this helps people out, if anyone has any questions feel free to comment here with them.
Script:
<?php
// Code written by DanielRHarris (DanielRH)
// Code written for VectronCraft (IP: MC.VectronCraft.com -- Website: www.VectronCraft.com)
// Please leave this attribution.
// PHP Function to check whether the minecraft username ($mcUser) is a premium minecraft account holder
function check_user($mcUser)
{
// $check_mcUser gets the contents of the file from minecraft.net that does the checking for premium user
$check_mcUser = file_get_contents('http://www.minecraft.net/haspaid.jsp?user='.$mcUser.'');
// If $check_mcUser is true (premium user), it executes the code within
if ($check_mcUser == 'true') {
echo 'Username Is Premium!';
}
// If $check_mcUser is not true, it executes the code within the else statement
else {
echo 'Username Not Premium.';
}
}
// Please comment/uncomment a method you would like to use to recieve the username (leave only one activated at once and comment the others out with a // at the begginning of the line
// Gets the username from a form submit, or via url (eg. www.example.com/checkuser.php?mcUser=DanielRHarris):
$mcUser = $_GET["mcUser"];
// Declares the username right here within the quotes:
//$mcUser = 'DanielRHarris';
// Executes function that checks whether the user is a premium minecraft account holder
check_user($mcUser);
?>
I wrote a small script to do just that, it receives a username and checks the username against Minecraft.net's list of premium usernames.
Hope this helps people out, if anyone has any questions feel free to comment here with them.
Script:
Long live the creeper! Ssssss.....BOOM
/DanielRH