PHP code example of olexandrmazur / api-slack-php
1. Go to this page and download the library: Download olexandrmazur/api-slack-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/ */
olexandrmazur / api-slack-php example snippets
use Frlnc\Slack\Http\SlackResponseFactory;
use Frlnc\Slack\Http\CurlInteractor;
use Frlnc\Slack\Core\Commander;
$interactor = new CurlInteractor();
$interactor->setResponseFactory(new SlackResponseFactory());
// or
// $interactor = new CurlInteractor(new SlackResponseFactory());
const API_TOKEN = 'xoxb-some-token-for-slack';
const CHANNEL_ID = 'C01SF1KFPPP';
$commander = new Commander(API_TOKEN, $interactor);
$response = $commander->execute(
'chat.postMessage',
[
'channel' => CHANNEL_ID,
'text' => 'Hello, world!'
]
);
if ($response['ok']) {
// Command worked
} else {
// Command didn't work
}
composer