интеграция bitrix24 и radicalform
<?php | |
defined('_JEXEC') or die; | |
// формируем URL в переменной $queryUrl | |
$queryUrl = 'https://[ваше_название].bitrix24.ru/rest/[идентификатор_пользователя]/[код_вебхука]/crm.lead.add.json'; | |
//проверяем существование передаваемых переменных | |
if(isset($source['name'])) | |
{ | |
$contact_name=$source['name']; | |
} | |
else | |
{ | |
$contact_name=''; | |
} | |
if(isset($source['phone'])) | |
{ | |
$contact_phone=$source['phone']; | |
} | |
else | |
{ | |
$contact_phone=''; | |
} | |
if(isset($source['email'])) | |
{ | |
$contact_email=$source['email']; | |
} | |
else | |
{ | |
$contact_email=''; | |
} | |
if(isset($source['rfSubject'])) | |
{ | |
$contact_subject=$source['rfSubject']; | |
} | |
else | |
{ | |
$contact_subject='Лид'; | |
} | |
// формируем параметры для создания лида в переменной $queryData | |
$queryData = http_build_query(array( | |
'fields' => array( | |
'TITLE' => $contact_subject, | |
'EMAIL' => Array( | |
"n0" => Array( | |
"VALUE" => $contact_email, | |
"VALUE_TYPE" => "WORK", | |
), | |
), | |
'PHONE' => Array( | |
"n0" => Array( | |
"VALUE" => $contact_phone, | |
"VALUE_TYPE" => "WORK", | |
), | |
), | |
'NAME' => $contact_name | |
), | |
'params' => array("REGISTER_SONET_EVENT" => "Y") | |
)); | |
// обращаемся к Битрикс24 при помощи функции curl_exec | |
$curl = curl_init(); | |
curl_setopt_array($curl, array( | |
CURLOPT_SSL_VERIFYPEER => 0, | |
CURLOPT_POST => 1, | |
CURLOPT_HEADER => 0, | |
CURLOPT_RETURNTRANSFER => 1, | |
CURLOPT_URL => $queryUrl, | |
CURLOPT_POSTFIELDS => $queryData, | |
)); | |
$result = curl_exec($curl); | |
curl_close($curl); | |
$result = json_decode($result, 1); | |
if (array_key_exists('error', $result)) echo "Ошибка при сохранении лида: ".$result['error_description']."<br/>"; |
This comment has been minimized.
This comment has been minimized.
Ага. Делал такое. |
This comment has been minimized.
This comment has been minimized.
спасибо за дополнительную информацию! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This comment has been minimized.
создано на основе руководства https://gettotop.ru/crm/bitrix24-lidy-s-sajta-avtomaticheskoe-sozdanie-lidov