1. Go to this page and download the library: Download lygav/php-slackbot 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/ */
lygav / php-slackbot example snippets
$bot = new Slackbot("https://hooks.slack.com/services/your/incoming/hook");
$bot->text("Hi")->send();
$bot->attach(
$bot->buildAttachment("fallback text")
->enableMarkdown()
->setText("We can have *mrkdwn* `code` _italic_ also in attachments")
)
->toGroup("mygroup")
->send();
$attachment = $bot->buildAttachment("fallback text"/* mandatory by slack */)
->setPretext("pretext line")
->setText("attachment body text")
/*
Human web-safe colors automatically
translated into HEX equivalent
*/
->setColor("lightblue")
->setAuthor("me")
->addField("short field", "i'm inline", TRUE)
->addField("short field 2", "i'm also inline", TRUE)
->setImageUrl("http://my-website.com/path/to/image.jpg");
$bot->attach($attachment)->send();
$options = array(
'username' => 'my-bot-name',
'icon_emoji' => ':icon name:',
'icon_url' => 'http://someicon.com',
'channel' => '#test-channel'
);
$bot = new Slackbot($url, $options);
$bot->text("check out bot new icon")->send();
// Choose to override 'last minute' (ex. when dealing with multiple consequtive messages)
$bot->text("check out bot new icon")->send(array("username" => "other-bot-name"));
$handler = new MockHandler();
$bot = new SlackBot($url, ['handler' => $handler]);
$bot->text("some text")
->from("my-test-bot")
->toGroup("bot-testing")
->send();
json
"lygav/php-slackbot": "0.0.*"
}
php makephar
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.