2017 © Pedro Peláez
 

library mattermost-php

Mattermost PHP driver to send incoming webhooks

image

thibaud-dauce/mattermost-php

Mattermost PHP driver to send incoming webhooks

  • Tuesday, March 6, 2018
  • by ThibaudDauce
  • Repository
  • 4 Watchers
  • 16 Stars
  • 7,658 Installations
  • PHP
  • 4 Dependents
  • 0 Suggesters
  • 4 Forks
  • 0 Open issues
  • 3 Versions
  • 18 % Grown

The README.md

Mattermost PHP Driver

This driver for Mattermost allows you to send message for incoming webhooks., (*1)

Installation

Install project with composer, (*2)

  composer require thibaud-dauce/mattermost-php

Usage/Examples

This is a full example from tests/test.php:, (*3)

<?php

require __DIR__ . '/../vendor/autoload.php';

use GuzzleHttp\Client;
use ThibaudDauce\Mattermost\Mattermost;
use ThibaudDauce\Mattermost\Message;
use ThibaudDauce\Mattermost\Attachment;

$mattermost = new Mattermost(new Client);

$message = (new Message)
    ->text('This is a *test*.')
    ->channel('tests')
    ->username('A Tester')
    ->iconUrl('https://upload.wikimedia.org/wikipedia/fr/f/f6/Phpunit-logo.gif')
    ->attachment(function (Attachment $attachment) {
        $attachment->fallback('This is the fallback test for the attachment.')
            ->success()
            ->pretext('This is optional pretext that shows above the attachment.')
            ->text('This is the text. **Finaly!**')
            ->authorName('Mattermost')
            ->authorIcon('http://www.mattermost.org/wp-content/uploads/2016/04/icon_WS.png')
            ->authorLink('http://www.mattermost.org/')
            ->title('Example attachment', 'http://docs.mattermost.com/developer/message-attachments.html')
            ->field('Long field', 'Testing with a very long piece of text that will take up the whole width of the table. And then some more text to make it extra long.', false)
            ->field('Column one', 'Testing.', true)
            ->field('Column two', 'Testing.', true)
            ->field('Column one again', 'Testing.', true)
            ->imageUrl('http://www.mattermost.org/wp-content/uploads/2016/03/logoHorizontal_WS.png')
            ->action([
                'name' => 'Some button text',
                'integration' => [
                    'url' => 'https://my-post-api.example.org',
                    'context' => [
                        'user_id' => '123',
                        'secret_key' => 'bépo22',
                    ],
                ]
            ]);
    });

$mattermost->send($message, 'https://your_mattermost_webhook_url');

You can play with it by running php tests/test.php after setting your incoming webhook URL for your server., (*4)

The Versions

06/03 2018

dev-master

9999999-dev https://github.com/thibaud-dauce/mattermost-php

Mattermost PHP driver to send incoming webhooks

  Sources   Download

MIT

The Requires

 

06/03 2018

1.1.1

1.1.1.0 https://github.com/thibaud-dauce/mattermost-php

Mattermost PHP driver to send incoming webhooks

  Sources   Download

MIT

The Requires

 

29/08 2016

1.0.0

1.0.0.0 https://github.com/thibaud-dauce/mattermost-php

Mattermost PHP driver to send incoming webhooks

  Sources   Download

MIT

The Requires