A
A
Alexander2021-08-02 19:16:38
Bitrix24
Alexander, 2021-08-02 19:16:38

How to display a list of infoblock elements through a webhook?

I have a boxed version of Bitrix24. It is necessary to display data on lists from Bitrix24 on another site that works on BUS.

How to display a list of infoblock elements in the PHP code of a third-party site from the boxed version of Bitrix24 through a webhook?

The documentation contains only a JS example of how to display infoblock elements via the REST API https://dev.1c-bitrix.ru/rest_help/lists/lists/lis...

I tried to display infoblock elements from Bitrix24 via a webhook. On the side of Bitrix24, I created a webhook and specified the necessary rights to display Lists (lists) and CRM and users (users).

6108180e29b4c683396002.png

In the code, I refer to the webhook address where I specify the lists.get method, but we return an array where the ERROR_METHOD_NOT_FOUND error is indicated.

My PHP code is on the BUS side

$queryUrl = 'https://мой адрес/rest/27/wu939soul79dnt6h/';
$queryData = http_build_query(array(
    'IBLOCK_TYPE_ID'=>'lists',
      'IBLOCK_ID'=>'25'
  ));
  
  $rest = 'lists.get';	
  $queryUrl = $queryUrl.$rest;	
  $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, true);	

var_dump($result);


What am I doing wrong?

I assumed that the code would work, since I previously wrote a similar code to receive data on a separate lead from Bitrix24, the data comes in, everything works fine.

Here is a working code where I receive data on a lead from Bitriix24 through a webhook, specifying the ID parameter of the desired lead
$queryUrl = 'https://мой адрес/rest/27/wu939soul79dnt6h/';
$data = [];
$data['ID'] = 595;

// Получаем поля необходимого лида по айди
  $queryData = http_build_query(array(
    'id' => $data['ID']
  ));
  
  $rest = 'crm.lead.get';	
  $queryUrl = $queryUrl.$rest;	
  $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, true);	

var_dump($result);

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question