Here's an easy to use PHP wrapper class for the XboxMB API.
PHP Code:
class RequestMode
{
const Username = 'u';
const UserID = 'uid';
const Minecraft = 'mc';
}
class XboxMB
{
private $userData;
public function __get($userVar)
{
return $this->userData->$userVar;
}
public function loadUser($mode, $data)
{
$req = curl_init();
curl_setopt($req, CURLOPT_URL, "http://api.xboxmb.com/?$mode=" . urlencode($data));
curl_setopt($req, CURLOPT_RETURNTRANSFER, true);
$this->userData = json_decode(curl_exec($req));
curl_close($req);
return $this->userData ? $this->Valid : false;
}
public static function GetUser($mode, $data)
{
$xmbUser = new XboxMB();
return $xmbUser->loadUser($mode, $data) ? $xmbUser : false;
}
}
XboxMB::GetUser will return FALSE if the user isn't found.
Otherwise, it will return the user object. The Modes:
Username - Look-up a user by their username
UserID - Look-up a user by their unique user ID
Minecraft - Reverse look-up a user by their Minecraft username
Example Usage: PHP Code:
$xmbUser = XboxMB::GetUser(RequestMode::Username, 'Cheater912');
echo 'Cheater912 has ' . $xmbUser->Posts . ' posts on XboxMB.com!';