A
A
Artem Volkov2020-03-05 19:46:10
PHP
Artem Volkov, 2020-03-05 19:46:10

How to get the entire list of calls from Bitrix24 (telephony) REST API?

Hello.
The task is simple at first glance. You need to get the entire list of calls for the day. I use PHP

$webhook = 'https://test.bitrix24.ua/rest/1/.../voximplant.statistic.get'; // 
$data = http_build_query([
    // array code...
    'SORT' => 'ID',
    'ORDER' => 'DESC',
    'filter' => [
      '>CALL_START_DATE' => date('Y').'-'.date('m').'-'.date('d'),
      // 'CALL_FAILED_CODE' => [304],
    ]
  ]);
$curl = curl_init();
curl_setopt_array($curl, [
  // array code...
  CURLOPT_SSL_VERIFYPEER => 0,
  CURLOPT_POST => 1,
  CURLOPT_HEADER => 0,
  CURLOPT_RETURNTRANSFER => 1,
  CURLOPT_URL => $webhook,
  CURLOPT_POSTFIELDS => data(),
]
);
$result = curl_exec($curl);
$result = json_decode($result, 1);

echo '<pre>';
print_r($result['result']);
echo '</pre>';

But as you know, Bitrix gives out only 50 records. How to get a complete list?
PS - And can you tell me who knows. Main task: - get a list of calls with code 304 (304 - missed call), BUT! - if since the date of the missed call, an entry with this number has appeared, but already with the code 200, then do not show it. Perhaps this can be sent to a Bitrix request and immediately get the result?
// пример массива
$array = [
  'result' => [
    /*
      Принятый звонок (перезвонили) в 18:00:00
      номер: 08001234567
      код: 200
      ! Значит запись с ключем 20 не показывать
    */
    0 => [
      'ID' => '100',
      'USER_NUMBER' => '08001234567',
      'CODE' => '200',
      'DATE' => '2020.03.05Т18:00:00+03:00'
    ],
    /*
      Пропущенный звонок в 10:00:00
      номер: 08001234567
      код: 304
    */
    20 => [
      'ID' => '80',
      'USER_NUMBER' => '08001234567',
      'CODE' => '304',
      'DATE' => '2020.03.05Т10:00:00+03:00'
    ],
    /*
      Пропущенный звонок в 08:00:00
      номер: 08000000777
      код: 304
      ! Данный звонок показать, так-как на него еще
        нет записи с кодом 200.
    */
    45 => [
      'ID' => '60',
      'USER_NUMBER' => '08000000777',
      'CODE' => '304',
      'DATE' => '2020.03.05Т08:00:00+03:00'
    ],
  ]
];

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dim, 2020-03-12
@Dee3

You need to use the batch method, see the documentation for this word.

E
Eugene, 2020-03-15
@ujy666

https://dev.1c-bitrix.ru/rest_help/general/lists.php

When calling list methods, REST returns additional values ​​in the response:
To get the next batch of elements, you must execute the same request, specifying an additional start parameter with the value that came in the next parameter of the response.

https://dev.1c-bitrix.ru/rest_help/general/batch.php
In some cases, it becomes necessary to send several requests in a row. You can use batch query execution to streamline the process.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question