ааа - 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 ааа.php
- <?php
- $tg_user = '-1001981101116'; // id пользователя, которому отправиться сообщения
- $bot_token = '6245610714:AAFFSV5zR4UJhOpfudcTilbRQxHO2Y17Cxg'; // токен бота
- if (isset($_POST['tildaspec-formname']) && !empty($_POST['tildaspec-formname'])) {
- $txt .= "Тема заявки: " . strip_tags(trim(urlencode($_POST['tildaspec-formname']))) . "\n";
- }
- if (isset($_POST['names']) && !empty($_POST['names'])) {
- $txt .= "Имя: " . strip_tags(trim(urlencode($_POST['names']))) . "\n";
- }
- if (isset($_POST['name']) && !empty($_POST['name'])) {
- $txt .= "Имя: " . strip_tags(trim(urlencode($_POST['name']))) . "\n";
- }
- // Номер телефона
- if (isset($_POST['phone']) && !empty($_POST['phone'])) {
- $txt .= "Телефон: " . strip_tags(trim(urlencode($_POST['phone']))) . "\n";
- }
- $params = array(
- 'chat_id' => $tg_user, // id получателя сообщения
- 'text' => $txt, // текст сообщения
- 'parse_mode' => 'HTML', // режим отображения сообщения, не обязательный параметр
- );
- $curl = curl_init();
- curl_setopt($curl, CURLOPT_URL, 'https://api.telegram.org/bot' . $bot_token . '/sendMessage'); // адрес api телеграмм
- curl_setopt($curl, CURLOPT_POST, true); // отправка данных методом POST
- curl_setopt($curl, CURLOPT_TIMEOUT, 10); // максимальное время выполнения запроса
- curl_setopt($curl, CURLOPT_POSTFIELDS, $params); // параметры запроса
- $result = curl_exec($curl); // запрос к api
- curl_close($curl);
- var_dump(json_decode($result));
- ?>