13) { return 0; } return Sms::send($phone, $text); } /** * Получает параметр из POST или GET (с приоритетом POST). * * @param string $key Название параметра. * @return string|null */ function get_request_param($key) { return filter_input(INPUT_POST, $key) ?? filter_input(INPUT_GET, $key); } // Получаем параметры запроса $phone = get_request_param('to'); $sms_text = get_request_param('text'); // Если оба параметра присутствуют if (!empty($phone) && !empty($sms_text)) { $result = send_sms($phone, $sms_text); if (!empty($result) && is_array($result)) { foreach ($result as $recipient => $statusJson) { $status = json_decode($statusJson, true, 512, JSON_OBJECT_AS_ARRAY); if (isset($status["data"]["id"], $status["data"]["status"])) { echo htmlspecialchars($recipient) . ':' . htmlspecialchars($status["data"]["id"]) . ':' . htmlspecialchars($status["data"]["status"]) . '
'; } } } } // Очистка переменных (необязательно, но на всякий случай) unset($_GET, $_POST); ?>