PHP code example of kosmosafive / kosmos.linemessage

1. Go to this page and download the library: Download kosmosafive/kosmos.linemessage 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/ */

    

kosmosafive / kosmos.linemessage example snippets


use Bitrix\Main\Loader;
use Kosmos\LineMessage\Line;
use Kosmos\LineMessage\Sender;

Loader::'ANOTHER_TEMPLATE');
    
$lineCollection = new Line\Collection(
    $someTemplateLine,
    $anotherTemplateLine
);

$oneMoreTemplateLine = new Line\Email('ONE_MORE_TEMPLATE', true);

$lineCollection->add($oneMoreTemplateLine);

$context = ['EMAIL' => '[email protected]'];

$lineResultCollection = (new Sender($lines, $context))->send();

$lineResultCollection->isSuccess(); // true, если все сообщения были отправлены
$lineResultCollection->isHandled(); // true, если все каналы обработаны

$lineResultCollection->getSuccessCollection(); // коллекция отправленных
$lineResultCollection->getFailureCollection(); // коллекция неотправленных
$lineResultCollection->getHandledCollection(); // коллекция обработанных
$lineResultCollection->getUnhandledCollection(); // коллекция необработанных

$someTemplateLineResult = $lineResultCollection->findByLine($someTemplateLine);

$someTemplateLineResult->isSuccess(); // true, если сообщение было отправлено
$someTemplateLineResult->isHandled(); // true, если канал обработан