PHP Mojang API 1.4

A easy-to-use PHP class for accessing official Mojang's API

  1. MTC
    .
    [​IMG]



    Description
    A easy-to-use PHP class for accessing official Mojang's API.
    This include UUID to username conversion, get Mojang status, or fetch user's skin/head.


    Installation
    First you need to download the resource, and require mojang-api.class.php. Other files are not needed in your project.

    So it's simple as this:
    Code (PHP):
    // Require API
    require 'mojang-api.class.php';

    Usage
    A lot of sample code and example case are in example.php file, also be sure to check mojang-api.interface.php file to see all methods available.

    Code (PHP):
    // Require API
    require 'mojang-api.class.php';

    // Get UUID from username
    $uuid = MojangAPI::getUuid('MTC');
    echo 'UUID: <b>' . $uuid . '</b><br>';

    // Get his name history
    $history = MojangAPI::getNameHistory($uuid);
    echo 'First username: <b>' . reset($history)['name'] . '</b><br>';

    // Print player's head
    $img = '<img src="' . MojangAPI::embedImage(MojangAPI::getPlayerHead($uuid)) . '" alt="Head of MTC">';
    echo 'Skin:<br>' . $img . '<br>';

    // Query a server
    $query = MojangAPI::query('play.onecraft.fr', 25565);
    if ($query) echo 'There is ' . $query['players'] . ' players online out of ' . $query['maxplayers'] . '<br>';
    else echo 'Server is offline.<br>';

    This code will result in:
    [​IMG]


    Github
    Code source is fully available on Github here: https://github.com/MineTheCube/MojangAPI
    Don't hesitate to report issues or send pull request if needed !
    .

Recent Reviews

  1. Koora
    Koora
    5/5,
    Version: 1.4
    Awesome, a very good api to ping your own server !
    I recommand !................
    1. MTC
      Author's Response
      Thanks for the review :D
  2. Bigg_Daddyy
    Bigg_Daddyy
    5/5,
    Version: 1.4
    Awesome Thanks! so easy to use and just works! :D Love you keep it up ;)........
    1. MTC
      Author's Response
      Thanks! :D
  3. LeonardJKE
    LeonardJKE
    5/5,
    Version: 1.4
    Thanks for this amaizing php class. Already almost one and a half year I use this class for my monitoring
    1. MTC
      Author's Response
      Thank you :)
  4. TOminerTV
    TOminerTV
    3/5,
    Version: 1.4
    It is really nice, but get Heads of any Player wont work! :(
    Please help, then there are 5 stars in it! :D
  5. krityug
    krityug
    5/5,
    Version: 1.4
    I love this plugin.I was wondering a plugin that we install and give us the player data in a gui.
    1. MTC
      Author's Response
      Thanks for reviewing!
  6. Azen0x
    Azen0x
    5/5,
    Version: 1.4
    Pffff. So beautiful, so useful. This API deserve more than 100 stars. Thanks for this tool !
    1. MTC
      Author's Response
      And thank you for the review!
  7. Two
    Two
    5/5,
    Version: 1.4
    This is amazing! You just made my work a lot easier (and code cleaner). Overall an amazing resource.
    1. MTC
      Author's Response
      Thanks for your review! ;)
  8. cowgod
    cowgod
    5/5,
    Version: 1.4
    I was able to use this API to parse an old database with 5,700 player records to get their UUID and most recent username. I was then able to output formatted Spigot console commands that would apply player balances on our new economy plugin. It worked flawlessly. Thank you for making this API, it's super simple to use!
    1. MTC
      Author's Response
      Glad that it helped! :D
  9. 24763
    24763
    5/5,
    Version: 1.4
    Amazing resource! Was searching for ages and i finally find something that works! Developer helped me with a few issues too! <3
    1. MTC
      Author's Response
      Thank you for reviewing :)
  10. brainsynder
    brainsynder
    5/5,
    Version: 1.3
    This is an amazing resource, I use it on some of my website pages like my chat page and I will definatly be using more of it in the future.
    1. MTC
      Author's Response
      Thank you for the review mate !