magic_decode_token($_GET['token']);

function magic_decode_token(string $token)
{
    $url = "https://magic.mk/api/validate/";
    $xapikey = [YOUR_API_KEY];
    $body = json_encode(['token' => $token]);

    $ch = curl_init($url);

    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_HTTPHEADER, [
        'Content-Type: application/json',
        'X-API-Key: ' . $xapikey,
    ]);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
    curl_setopt($ch, CURLOPT_TIMEOUT, 60);

    $response = curl_exec($ch);
    $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    curl_close($ch);

    if ($http_code !== 200) {
        echo "Something went wrong with the Magic Login plugin. ERROR:" . $http_code";
        return;
    }

    return json_decode($response);
}