123321 - PHP Online
Form of PHP Sandbox
Enter Your PHP code here for testing/debugging in the Online PHP Sandbox. As in the usual PHP files, you can also add HTML, but do not forget to add the tag <?php
in the places where the PHP script should be executed.
Result of php executing
Full code of 123321.php
- <?php
- // Замените YOUR_BOT_TOKEN на токен вашего бота
- define('BOT_TOKEN', '6690344501:AAEvH0OZc_xMJVhT6OIIRvhUgj4Ql1-tlQ4');
- // Задаем URL для API Telegram
- $api_url = 'https://api.telegram.org/bot' . BOT_TOKEN . '/';
- // Получаем данные о сообщении от пользователя
- $update = json_decode(file_get_contents('php://input'), true);
- // Получаем ID чата и текст сообщения
- $chat_id = $update['message']['chat']['id'];
- $message_text = $update['message']['text'];
- // Отправляем ответное сообщение пользователю
- sendMessage($chat_id, "Вы написали: $message_text");
- // Функция для отправки сообщения пользователю
- function sendMessage($chat_id, $message) {
- global $api_url;
- $params = [
- 'chat_id' => $chat_id,
- 'text' => $message,
- ];
- $url = $api_url . 'sendMessage?' . http_build_query($params);
- file_get_contents($url);
- }
- ?>
File Description
- 123321
- PHP Code
- 18 Feb-2024
- 1.01 Kb
You can Share it:
Latest PHP Pastes