Answer the question
In order to leave comments, you need to log in
Do not receive leads from the site to modx?
Good afternoon! There is a form call using the AjaxForm and Formit snippets:
<form action="" class="header-form ajax_form" method="post" id="header-form">
<div class="d-none">
<label>Имя</label>
<input type="text" placeholder="" name="user">
<input type="text" placeholder="" name="username">
</div>
<div class="header-form-wrapper">
<div class="header-form-block">
<input class="header-form__input" type="text" name="name" placeholder="Введите имя" value=>
<span class="error error_name"></span>
</div>
<div class="header-form-block">
<input class="header-form__input" type="tel" name="phone" placeholder="Номер телефона" value=>
</div>
</div>
<button class="header-form__button">Заказать звонок</button>
</form>
<?php
// CRM server connection data
define('CRM_HOST', 'домен.bitrix24.ru'); // your CRM domain name
define('CRM_PORT', '443'); // CRM server port
define('CRM_PATH', '/crm/configs/import/lead.php'); // CRM server REST service path
// CRM server authorization data
define('CRM_LOGIN', 'логин'); // login of a CRM user able to manage leads
define('CRM_PASSWORD', 'пароль'); // password of a CRM user
// OR you can send special authorization hash which is sent by server after first successful connection with login and password
//define('CRM_AUTH', 'e54ec19f0c5f092ea11145b80f465e1a'); // authorization hash
/********************************************************************************************/
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$name = $_POST['name'];//получаем данные из поля имя
$phone = $_POST['phone']; //получаем данные из поля телефон
$postData = array(
'TITLE' => 'заявка с сайта', // заголовок для лида
'NAME' => $name, // передаем поле имя в Битрикс
'PHONE_WORK' => $phone, // передаем поле телефон в Битрикс
);
$fp = fsockopen("ssl://".CRM_HOST, CRM_PORT, $errno, $errstr, 30);
if ($fp)
{
// prepare POST data
$strPostData = '';
foreach ($postData as $key => $value)
$strPostData .= ($strPostData == '' ? '' : '&').$key.'='.urlencode($value);
// prepare POST headers
$str = "POST ".CRM_PATH." HTTP/1.0\r\n";
$str .= "Host: ".CRM_HOST."\r\n";
$str .= "Content-Type: application/x-www-form-urlencoded\r\n";
$str .= "Content-Length: ".strlen($strPostData)."\r\n";
$str .= "Connection: close\r\n\r\n";
$str .= $strPostData;
// send POST to CRM
fwrite($fp, $str);
// get CRM headers
$result = '';
while (!feof($fp))
{
$result .= fgets($fp, 128);
}
fclose($fp);
// cut response headers
$response = explode("\r\n\r\n", $result);
$output = '<pre>'.print_r($response[1], 1).'</pre>';
}
else {
echo 'Connection Failed! '.$errstr.' ('.$errno.')';
}
}
else {
$output = '';
}
?>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question