PHP code example of baruchyan / bitrix-exchange

1. Go to this page and download the library: Download baruchyan/bitrix-exchange library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

baruchyan / bitrix-exchange example snippets


const FILE_DIR = '1c_messages'; 

protected function fillResponseTypeMap(): void
{
    $this->responseTypeMap = [
        'checkauth' => 'text',
        'query' => 'json',
        'file' => 'json',
        'import' => 'json'
    ];
}

protected function modeQuery(): void
 {
     // получем сообщения
     $messages = $this->getMessages();

     // обновляем статус выгрузки
     if(!empty($this->messageIds)){
         $this->updateMessages();
     }

     $this->response->addResponseField('messages', $messages);
     $this->response->setSuccessStatus();
 }

protected function modeCheckauth(): void
{
    // ...
}

$exchange = new \Project\Exchanges\Message();
$exchange->printFormatResponse();
 
$response = $exchange->getResponse();