Last active
November 26, 2020 14:53
-
-
Save progreccor/fae1b97b4af4fc83a7ed552f9db4bd8b to your computer and use it in GitHub Desktop.
интеграция bitrix24 и radicalform
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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/>"; |
Ага. Делал такое.
Чуть более инфы для Битрикса в json.
$queryData = http_build_query(array( 'fields' => array( 'TITLE' => 'Лид с сайта', 'NAME' => $contact_name, 'ASSIGNED_BY_ID' => "11", // кого назначить ответственным за лида "STATUS_ID" => "NEW", "OPENED" => "Y", 'COMMENTS' => $contact_firm, // комментарий к лиду 'PHONE' => array( array( "VALUE" => $contact_phone, "VALUE_TYPE" => "WORK" ) ) ), 'params' => array("REGISTER_SONET_EVENT" => "Y") ));
Ну, и там у нас три поля было. Номер, имя и организация.
спасибо за дополнительную информацию!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
создано на основе руководства https://gettotop.ru/crm/bitrix24-lidy-s-sajta-avtomaticheskoe-sozdanie-lidov