我正在尝试使用mojang api
从用户名中检索用户Minecraft UUID
这就是我所拥有的:
//Get Player UUID from name
$uuid = "Error obtaining uuid";
$json = file_get_contents('https://api.mojang.com/users/profiles/minecraft/' + $_GET['name']);
$obj = json_decode($json);
$uuid = $obj->id;
变量$uuid
包含null,我不知道我做错了什么我确保通过转到$_GET
设置player.php/?name=_Joosh
参数但仍然没有?
答案 0 :(得分:1)
您必须使用//Get Player UUID from name
$name = 'john';
$uuid = "Error obtaining uuid";
// Tested with simple variable
// $json = file_get_contents('https://api.mojang.com/users/profiles/minecraft/' . $name);
$json = file_get_contents('https://api.mojang.com/users/profiles/minecraft/' . $_GET['name']);
$obj = json_decode($json);
$uuid = $obj->id;
print $uuid;
opearator进行连接而不是加号。请尝试以下代码段。
array_equal