1. Go to this page and download the library: Download cian/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/ */
use Cian\Slack\SlackMethod;
$token = 'your-app-token';
$response = (new SlackMethod)
->setToken($token)
->usersList();
use Cian\Slack\SlackMethod;
$token = 'your-app-token';
$response = (new SlackMethod)
->setToken($token)
->usersLookupByEmail($email);
use Cian\Slack\IncomingWebhook;
$url = 'https://hooks.slack.com/services/path/to/your/incoming-webhook/url';
(new IncomingWebhook)->send($message, $url);
use Cian\Slack\InteractiveMessage;
$token = 'your-app-token';
// $channel can be channel_name, channel_id, user_slack_id
// but Slack suggests not to use channel_name.
$channel = 'development';
$message = 'Hello Interactive Message!';
(new InteractiveMessage([
'token' => $token,
'channel' => $channel
]))->send($message);
// or
(new InteractiveMessage)
->setToken($token)
->to($channel)
->send($message);
use Cian\Slack\IncomingWebhook;
use Cian\Slack\Builders\BlockBuilder;
$url = 'https://hooks.slack.com/services/path/to/your/incoming-webhook/url';
$builder = (new BlockBuilder)
->section('*A Title Here*')
->section('body content ...')
->divider()
->section('😗😗😗');
(new IncomingWebhook)->send($builder, $url)
use Cian\Slack\IncomingWebhook;
use Cian\Slack\Builders\BlockBuilder;
use Cian\Slack\Builders\AttachmentBuilder;
$blockBuilder = (new BlockBuilder)->section('How are you?');
// when you provide block builder as the first argument
// the second argument color will be applied
// the color can be 'good', 'warning', 'danger' or any valid hex color code.
$attachments = (new AttachmentBuilder($blockBuilder, '#ff0000'));
$url = 'https://hooks.slack.com/services/path/to/your/incoming-webhook/url';
(new IncomingWebhook)
->send($attachments, $url);
use Cian\Slack\IncomingWebhook;
use Cian\Slack\Builders\AttachmentBuilder;
$attachments = (new AttachmentBuilder)->add([
'text' => '😗😗😗',
'fallback' => 'fall back text...',
'footer' => 'footer text...',
'color' => 'danger'
// ... more legacy fields
]);
$url = 'https://hooks.slack.com/services/path/to/your/incoming-webhook/url';
(new IncomingWebhook)
->send($attachments, $url);
use Cian\Slack\Message;
use Cian\Slack\IncomingWebhook;
use Cian\Slack\Builders\BlockBuilder;
use Cian\Slack\Builders\AttachmentBuilder;
$titleBlocker = (new BlockBuilder)
->section('Title row 😗😗😗');
$bodyBlocker = (new BlockBuilder)
->section('body content ...')
->divider();
$attachmenter = (new AttachmentBuilder($bodyBlocker, '#ff00ff'));
$message = new Message($titleBlocker);
$message->setAttachments($attachmenter);
$url = 'https://hooks.slack.com/services/path/to/your/incoming-webhook/url';
(new IncomingWebhook)
->send($message, $url);
use Cian\Slack\IncomingWebhook;
use Cian\Slack\Builders\BlockBuilder;
use Cian\Slack\Builders\ElementBuilder;
$text = 'Approve';
$actionId = 'approve_request';
$value = ['foo' => 'bar']; // optional default ''
$style = 'primary'; // optional default 'primary'
$type = 'plain_text'; // optional default `plain_text`
$button = ElementBuilder::makeButton($text, $actionId, $value, $style, $type);
// or $button = (new ElementBuilder)->button(/** same as makeButton */);
$blocker = (new BlockBuilder)
->section('*Can I buy a toy ?*')
->divider()
->actions([$button]);
$url = 'https://hooks.slack.com/services/path/to/your/incoming-webhook/url';
(new IncomingWebhook)->to($url)->send($blocker);
// or (new IncomingWebhook)->send($blocker, $url);