PHP code example of cjrasmussen / slack-api

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

    

cjrasmussen / slack-api example snippets


use cjrasmussen\SlackApi\SlackApi;

// INVITE A USER TO A CHANNEL
$slack = new SlackApi($token);

$args = [
    'channel' => 'C1234567',
    'member' => 'U9876543',
];
$slack->request('POST', 'conversations.invite', $args);

// SEND A MESSAGE VIA A SLACK WEBHOOK
$msg = [
    'text' => 'Message text',
];
$response = (new SlackApi($webhook_url))->sendMessage($msg);