PHP code example of moiseskalebe / slack-dispatcher-php

1. Go to this page and download the library: Download moiseskalebe/slack-dispatcher-php 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/ */

    

moiseskalebe / slack-dispatcher-php example snippets




declare(strict_types=1);

use MoisesK\SlackDispatcherPHP\Attachment;
use MoisesK\SlackDispatcherPHP\Collection\AttachmentFieldCollection;
use MoisesK\SlackDispatcherPHP\MessageDispatcher;
use MoisesK\SlackDispatcherPHP\Dto\AttachmentAuthor;
use MoisesK\SlackDispatcherPHP\Dto\AttachmentField;
use MoisesK\SlackDispatcherPHP\Dto\AttachmentFooter;
use MoisesK\SlackDispatcherPHP\Dto\AttachmentTitle;
use MoisesK\SlackDispatcherPHP\SlackAppMessage;

ar *negrito*, _itálico_, e [links](https://example.com) no texto.',
    'fields' => new AttachmentFieldCollection([
        new AttachmentField(
            title: 'campo 1',
            value: 'valor 1',
            short: false
        )
    ]),
    'imageUrl' => "https://example.com",
    'footer' => new AttachmentFooter(
        footer: 'Rodapé do anexo',
        footerIcon: "https://example.com"
    ),
    'ts' => '123456789'
]);

// Crie uma instância da classe SlackAppMessage
$slackMessage = new SlackAppMessage('https://hooks.slack.com/services/.....');

// Defina o texto do Cabeçalho da Mensagem
$slackMessage->setHeaderText('Texto da Mensagem');

// Adicione um Anexo
$slackMessage->addAttachment($attachment);

// Envie a mensagem para o app
$slackMessage->dispatch();
shell
composer