I'm trying to turn Minecraft names into UUIDs, which can be converted into a "name history". I have the name->UUID part down pat, but the name history is getting an error.
Running this code, the $uuid variable contains an array of all the UUIDs I'm trying to convert into a name history - I then try to run all of them through the API, and depending on how many past names the user has, add » icons to signify a change. Unfortunately, with test data of something like this:
Foo
Bar (changed to Baz)
it outputs
Array | Array » Array |
, not the
Foo | Bar » Baz |
it's supposed to. I know I'm probably getting the array as an object, but I don't know where I would be doing that or how to get the element instead.
(and here's the code)
$uuid_real = json_decode($uuid, TRUE);
foreach($uuid_real as $uuid_totest){
$toadd = json_decode(file_get_contents('https://api.mojang.com/user/profiles/' . $uuid_totest['id'] . '/names'), TRUE);
if(count($toadd)==1){
$results .= $toadd['0'] . " | ";
}elseif(count($toadd)==2){
$results .= $toadd['0'] . " » " . $toadd['1'] . " | ";
}elseif(count($toadd)==3){
$results .= $toadd['0'] . " » " . $toadd['1'] . " » " . $toadd['2'] . " | ";
}
Here is var_dump for $toadd with some currently online users:
array(1) {
[0]=>
array(1) {
["name"]=>
string(10) "lottie1664"
}
}
array(1) {
[0]=>
array(1) {
["name"]=>
string(12) "wingmanfoutz"
}
}
array(1) {
[0]=>
array(1) {
["name"]=>
string(11) "bigfoot2991"
}
}
array(1) {
[0]=>
array(1) {
["name"]=>
string(13) "mrstampycat05"
}
}
array(1) {
[0]=>
array(1) {
["name"]=>
string(10) "MEHLAWLARZ"
}
}
array(1) {
[0]=>
array(1) {
["name"]=>
string(10) "metboy2002"
}
}
array(1) {
[0]=>
array(1) {
["name"]=>
string(10) "SILVERMAN2"
}
}
array(2) {
[0]=>
array(1) {
["name"]=>
string(11) "salesman200"
}
[1]=>
array(2) {
["name"]=>
string(8) "Quartzic"
["changedToAt"]=>
int(1423055736000)
}
}
array(1) {
[0]=>
array(1) {
["name"]=>
string(13) "MercenaryCrow"
}
}
array(1) {
[0]=>
array(1) {
["name"]=>
string(8) "fishmeal"
}
}