Skip to content

Instantly share code, notes, and snippets.

@progreccor

progreccor/bitrix.php

Last active Nov 26, 2020
Embed
What would you like to do?
интеграция 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/>";
@progreccor

This comment has been minimized.

Copy link
Owner Author

@progreccor progreccor commented Jul 10, 2020

создано на основе руководства https://gettotop.ru/crm/bitrix24-lidy-s-sajta-avtomaticheskoe-sozdanie-lidov

2020-07-10_12-39-57

photo_2020-07-10_12-01-36

@cave2006

This comment has been minimized.

Copy link

@cave2006 cave2006 commented Jul 10, 2020

Ага. Делал такое.
Чуть более инфы для Битрикса в 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") ));
Ну, и там у нас три поля было. Номер, имя и организация.

@progreccor

This comment has been minimized.

Copy link
Owner Author

@progreccor progreccor commented Jul 10, 2020

спасибо за дополнительную информацию!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.