7sg/rocketchat-webhook

1.0.1 2021-02-19 07:59 UTC

README

A PHP interface to send requests to Rocket Chat incoming webhooks.

Install

composer require 7sg/rocketchat-webhook

Usage

Simple message

use Seven\RocketChatWebHook\Message as RocketChatMessage;
use Seven\RocketChatWebHook\RocketChat;

RocketChat::setEndPoint('https:/rocketchat.url');

$message = new RocketChatMessage('Hello!');
$message->setEmoji('🥳');

RocketChat::sendMessage($message, 'webhook-hash-and-channel');

Messages can also have attachments

You can find a full list of all fields here.

$attachment = new RocketChatMessage\Attachment();
$attachment->title = 'Title';
$attachment->title_link = 'https://test.test';
$attachment->fields = [
    [
        'title' => 'Test',
        'value' => 'value'
    ]
];

$message->addAttachment($attachment);