PHP code example of bt / rocketchat-php

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

    

bt / rocketchat-php example snippets




$client = new \RocketChatPhp\Client('https://demo.rocket.chat', 'webhook_token');
$client->payload([
    'text' => 'This will be sent to the webhook!'
]);

// Use this to toggle short or long text attachments.
$isShort = true;

$attachment = new \RocketChatPhp\Attachment('The text to be displayed if the client cannot load the attachment.', '#ffffff');
$attachment->addField('Field Title', 'Field Value', $isShort);
$attachment->addField('Field Title2', 'Field Value2', $isShort);

$client = new \RocketChatPhp\Client('https://demo.rocket.chat', 'webhook_token');
$client->payload([
    'text' => 'This is a test message with attachments!',
    'attachments' => [
    	$attachment->toArray()
    ]
]);

composer