PHP code example of frlnc / php-slack

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

    

frlnc / php-slack example snippets




use Frlnc\Slack\Http\SlackResponseFactory;
use Frlnc\Slack\Http\CurlInteractor;
use Frlnc\Slack\Core\Commander;

$interactor = new CurlInteractor;
$interactor->setResponseFactory(new SlackResponseFactory);

$commander = new Commander('xoxp-some-token-for-slack', $interactor);

$response = $commander->execute('chat.postMessage', [
    'channel' => '#general',
    'text'    => 'Hello, world!'
]);

if ($response['ok'])
{
    // Command worked
}
else
{
    // Command didn't work
}