var data = 'name=' + name + '&phone=' + phone + '&text= ' + message + '\n ' + window.location.hostname;
console.log('data = '+data);
$.ajax({
type: 'POST',
dataType: 'json',
url: 'http://fixi-pro.ru/ajax_order.php',
data: data,
success: function (data) {
form.trigger('reset');
if (data.status === true) {
$('[data-remodal-id=call-modal-success]').remodal().open();
try {
yaCounter46427409.reachGoal('OrderDone');
ga('send', 'event', 'KnopkaZakazaSFormy', 'Zayavka');
//gtag_report_conversion();
} catch (e) {
console.log(e.message)
}
} else {
$('[data-remodal-id=call-modal-error]').remodal().open();
}
}
});
});
<?php
$token = "bot463504725:AAHfhNNz_aJA4iqj59Sa0Nx5EVravRMX8kM";
$chatid = "-272771015";
$name = $_POST['name'];
$phone = $_POST['phone'];
$mes = $_POST['text'];
$mes2 = $_POST['text2'];
$msgs =
' Имя: '.$name.'
☎️ +'.$phone.'
Сообщение: '.$mes.'
'.$mes2.'
';
$messaggio = (new \DateTime())->format('H:i').'
'.$msgs;
$url = "https://api.telegram.org/" . $token . "/sendMessage?chat_id=" . $chatid;
$url = $url . "&text=" . urlencode($messaggio);
$ch = curl_init(data);
$optArray = array(
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true
);
// apply those options
curl_setopt_array($ch, $optArray);
// execute request and get response
$result = curl_exec($ch);
echo $result;
curl_close($ch);
echo 'Message to telegram was sent. res = '.$result.'<br>';
?>
echo json_decode(['status' => 'success']);
echo 'Message to telegram was sent. res = '.$result.'<br>';
$.ajax({
type: 'POST',
dataType: 'json',
url: 'http://fixi-pro.ru/ajax_order.php',
data: data,
success: function (data) {
form.trigger('reset');
if (data.status == 'success') {
// вызываем модальное окно, отправляем событие в метрику и ГА
} else {
// выдаем ошибку
}
}
});
$ch = curl_init(data);
<?php
$token = "bot463504725:AAHfhNNz_aJA4iqj59Sa0Nx5EVravRMX8kM";
$chatid = "-272771015";
$name = $_POST['name'];
$phone = $_POST['phone'];
$mes = $_POST['text'];
$mes2 = $_POST['text2'];
$msgs =
' Имя: '.$name.'
☎️ +'.$phone.'
Сообщение: '.$mes.'
'.$mes2.'
';
$messaggio = date('H:i').' '.$msgs;
$url = "https://api.telegram.org/" . $token . "/sendMessage?chat_id=" . $chatid . "&text=" . urlencode($messaggio);
$result = file_get_contents($url);
echo json_encode(['status' => 'success']);