I'm making a bot that returns Mojang's server status. Here's the code.
$scan = json_decode(file_get_contents("https://status.mojang.com/check"), true);
$errors = array();
if ($scan[0]["minecraft.net"] !== "green") {
array_push($errors, "Minecraft is down: ");
}
if ($scan[1]["session.minecraft.net"] !== "green" || $scan[6]["sessionserver.minecraft.net"] !== "green") {
array_push($errors, "All server sessions are down. ");
}
if ($scan[2]["account.minecraft.net"] !== "green") {
array_push($errors, "Account services are down. ");
}
if ($scan[3]["auth.minecraft.net"] !== "green" || $scan[5]["authserver.minecraft.net"] !== "green") {
array_push($errors, "Authentication servers are down. ");
}
if ($scan[4]["skins.minecraft.net"] !== "green") {
array_push($errors, "Skin servers are down. ");
}
$message = "Sometimes it's Mojang... ";
if (sizeof($errors) !== 0) {
foreach ($errors as $i) {
$message .= $errors[$i];
}
} else {
$message .= "but today, it seems like all of Mojang's servers are working fine!";
}
echo $message;
Whenever I execute this in my terminal, it outputs "Sometimes it's Mojang... ", and that's it. There's nothing else. Either way, if the if
is true or false, it will add something to the string, so it should be printing more than that, but it isn't. Any help would be appreciated, and sorry if this is an easy fix.
Thank you!