title: How to use the Mojang API with PHP
body: <p>The Mojang API allows you to access information related to the Players that play the game. There is a documenation to the API which can be found <a href="http://wiki.vg/Mojang_API" rel="nofollow">here</a>. However, since I am not so experienced with using an API , I'd like to know how to grab Username History of a Player. On the Documentation, under <code>UUID -&gt; Name history</code> there is a URL, <code>https://api.mojang.com/user/profiles/&lt;uuid&gt;/names</code>. I know how to get the UUID of a player, and by using the above URL in PHP, I get this output;</p>
  
  <hr>
  
  <pre><code>[{"name":"JizzInYaTaco22"},{"name":"_scrunch","changedToAt":1423047892000}]
  </code></pre>
  
  <hr>
  
  <p>How do I style this output to make it only show the names of the player? Here's a link showing what I'd like for it to show: <a href="http://i.imgur.com/UmBNBXp.jpg" rel="nofollow">Link</a></p>
  
  <p>Here's my code:</p>
  
  <p>$username comes from a form on a separate php page.
      
  
  <pre><code>$username = $_POST["username"];
  
  // Get the userinfo
  $content = file_get_contents('https://api.mojang.com/users/profiles/minecraft/' . urlencode($username));
  
  // Decode it
  $json = json_decode($content);
  
  
  // Save the uuid
  $uuid = $json-&gt;uuid;
  var_dump($json, $json-&gt;id, $uuid);
  // Get the history (using $json-&gt;uuid)
  $content = file_get_contents('https://api.mojang.com/user/profiles' . urlencode($uuid) . '/names');
  
  // Decode it
  $json = json_decode($content);
  
  $names = array(); // Create a new array
  
  foreach ($json as $name) {
      $names[] = $name-&gt;name; // Add each "name" value to our array "names"
  }
  
  echo 'UUID: ' . $uuid . '&lt;br /&gt;Name history: ' . implode(', ', $names);
  </code></pre>