if ($_SERVER['REQUEST_METHOD'] === 'GET') {
$deal_name = isset($_GET['name']) ? $_GET['name'] : '';
$deal_tel = isset($_GET['tel']) ? $_GET['tel'] : '';
$deal_vopros = isset($_GET['vopros']) ? $_GET['vopros'] : '';
} else {
$deal_vopros = "Данные могут быть отправлены только методом POST.";
}
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$deal_name = isset($_GET['name']) ? $_GET['name'] : '';
$deal_tel = isset($_GET['tel']) ? $_GET['tel'] : '';
$deal_vopros = isset($_GET['vopros']) ? $_GET['vopros'] : '';
} else {
$deal_vopros = "Данные могут быть отправлены только методом POST.";
}
<?php
include('vendor/autoload.php');
use Telegram\Bot\Api;
$telegram = new Api('5063232304:****');
$chat_id = -***;
$result = $telegram->getWebhookUpdates();
$result = json_decode($result, True);
$callback_data = $result['callback_query']['data'];
$callback_id = $result['callback_query']['message']['chat']['id'];
$callback_message_text = $result['callback_query']['message']['text'];
$callback_message_id = $result['callback_query']['message']['message_id'];
$callback_from = $result['callback_query']['from']['first_name'];
$text_message = $result['message']['text'];
// $deal_tel = $_GET['tel'];
// $deal_name = $_GET['name'];
// $deal_vopros = $_GET['vopros'];
if ($_SERVER['REQUEST_METHOD'] === 'GET') {
$deal_name = isset($_GET['name']) ? $_GET['name'] : '';
$deal_tel = isset($_GET['tel']) ? $_GET['tel'] : '';
$deal_vopros = isset($_GET['vopros']) ? $_GET['vopros'] : '';
} else {
$deal_vopros = "Данные могут быть отправлены только методом GET.";
}
$idRequest = "<strong>Форма:</strong> ";
$name = "\n<strong>Имя:</strong> ";
$telNumber = "<strong>Номер телефона:</strong> ";
$comment = "<strong>Комментарий:</strong> ";
$arr = array(
$idRequest => "Тест",
$comment => $deal_vopros,
$name => $deal_name,
$telNumber =>$deal_tel. "\n",
);
foreach ($arr as $key => $value) {
if ($key == " ") {
$txt .= " " . $key . " <em>" . $value . "</em>" . "\n";
} else {
$txt .= "" . $key . " <em>" . $value . "</em>" . "\n";
}
};
$telegram->sendMessage([
'chat_id' => $chat_id,
'text' => $txt,
'parse_mode' => 'html']);
$date = date('Y-m-d H:i:s');