if (isset($_GET['id'])) { $telegram_data = $_GET; if (!isset($telegram_data['hash'])) { echo "Нет параметра hash"; exit; } $check_hash = $telegram_data['hash']; unset($telegram_data['hash']); $data_check_arr = []; foreach ($telegram_data as $key => $value) { $data_check_arr[] = $key . '=' . $value; } sort($data_check_arr, SORT_STRING); $data_check_string = implode("\n", $data_check_arr); echo "
data_check_string:\n$data_check_string
"; $secret_key = hash('sha256', $bot_token, true); $hmac = hash_hmac('sha256', $data_check_string, $secret_key); echo "
Calculated hash: $hmac\nCheck hash: $check_hash
"; if ($hmac === $check_hash) { echo "Авторизация успешна"; // Здесь можно продолжить авторизацию } else { echo "Хэш не совпадает"; exit; } }