Documentation

Event Handler Testing

After registering the handler ONAPPTEST, call the method event.test. It triggers a specified event and ensure that handler is indeed able to receive event data.

Step 1

Create the file handler.php on your server. Make sure that it is accessible from the Internet. Create a \log folder next to the file.
Code for handler.php file:

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

Step 2

Register the event, by specifying the path to the file created in 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

Trigger the event by calling the method containing random data:

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

Result

Upon success, a file with standard events is created in the folder \log:

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


© «Bitrix Inc.», 2001-2021, «Bitrix Inc.», 2021