N
N
nikita-sidorenko2021-12-06 10:11:38
Bitrix24
nikita-sidorenko, 2021-12-06 10:11:38

How to specify a funnel when integrating requests from a site in Bitrix 24?

A simple integration of the collection of applications in Bitrix 24 is set up

<?php
define('CRM_HOST', 'login.bitrix24.ru'); // Указываем Ваш домен в CRM 
define('CRM_PORT', '443'); // Порт сервера CRM. Установлен по умолчанию, не меняем
define('CRM_PATH', '/crm/configs/import/lead.php'); 
define('CRM_LOGIN', '[email protected]'); // Логин пользователя Вашей CRM 
define('CRM_PASSWORD', 'pass'); // Пароль пользователя Вашей CRM 
if ($_SERVER['REQUEST_METHOD'] == 'POST') { 
    $name = $_POST['name'];// Получаем данные из поля Имя
    $phone = $_POST['phone']; // Получаем данные из поля Телефон
    $usermail = $_POST['email']; // Получаем данные из поля E-mail
    $product = $_POST['product']; // Получаем данные из скрытого поля названия товара
    if(!empty($_POST['comment'])) {
        $comment = $_POST['comment']; // Если есть комментарий, то получаем поле Комментарий
    }
 
   $postData = array(
      'TITLE' => 'Заявка с сайта', // Заголовок для лида
      'NAME' => $name, // Имя
      'PHONE_WORK' => $phone, // Телефон
      'EMAIL_WORK' => $usermail, // E-mail
      'COMMENTS' => $product.' '.$comment // Пользовательский комментарий
   );
   if (defined('CRM_AUTH'))
   {
      $postData['AUTH'] = CRM_AUTH;
   }
   else
   {
      $postData['LOGIN'] = CRM_LOGIN;
      $postData['PASSWORD'] = CRM_PASSWORD;
   }
   $fp = fsockopen("ssl://".CRM_HOST, CRM_PORT, $errno, $errstr, 30);
   if ($fp)
   {
      $strPostData = '';
      foreach ($postData as $key => $value)
         $strPostData .= ($strPostData == '' ? '' : '&').$key.'='.urlencode($value);
      $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;
      fwrite($fp, $str);
      $result = '';
      while (!feof($fp))
      {
         $result .= fgets($fp, 128);
      }
      fclose($fp);
      $response = explode("\r\n\r\n", $result);
      $output = '<pre>'.print_r($response[1], 1).'</pre>';
   }
   else
   {
      echo 'Connection Failed! '.$errstr.' ('.$errno.')';
   }
}
?>


But there is a peculiarity in Bitrix that there are several funnels (sales tunnels), by default all orders go to the first funnel, how can I specify during integration which funnel the order should go to?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey Nikolaev, 2021-12-09
@gromdron

But in Bitrix there is a feature that several funnels (sales tunnels)

There are no funnels and tunnels in leads, and you create a lead (/crm/configs/import/lead.php).
The fact that you have the "No Leads" mode means that it will automatically be converted into a deal.
In order to prevent the situation - use Webhook and specify the funnel where you want to create a deal.
how to specify during integration which funnel an order should go to?

Use the keys CATEGORY_ID and STAGE_ID

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question