Documentation

How to test your Bitrix24 event handler

After registering the ONAPPTEST handler, you need to manually call the method event.test. This action triggers the event and allows to verify, if the handler is capable of receiving event data.

Step 1

Create the file handler.php at your server. Ensure that it's accessible from the Internet. Create the folder \log next to the file.
Handler.php file code:

<?
file_put_contents(
   __DIR__ . '/log/' . time() . '.txt',
   var_export($_REQUEST, true)
);

Step 2

Register the event, by indicating the path to file (created at the step 1) in the field handler.

<?
$eventBind = CRest::call(
   'event.bind',
   [
      'event' => 'ONAPPTEST',
      'handler' => 'https://example.com/handler.php'
   ]
);
if($eventBind['result'])
{
   echo 'event bind successful';
}
?>

Step 3

Activate the event by calling the method with arbitrary data:

<?
$result = CRest::call(
   'event.test',
   [
      'any' => 'data'
   ]
);
if($result['result'])
{
   echo 'successful';
}
?>

Result

On success, creates the file with standard data for events in the folder \log:

array (
    'event' => 'ONAPPTEST',
    'data' => 
    array (
      'QUERY' => 
      array (
        'any' => 'data',
      ),
      'LANGUAGE_ID' => 'en',
    ),
    'ts' => '1573120286',
    'auth' => array (...)
)


© «Bitrix24», 2001-2024
Up