PHP code example of dealerinspire / slack-notifications
1. Go to this page and download the library: Download dealerinspire/slack-notifications 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/ */
dealerinspire / slack-notifications example snippets
$slackAttachmentConfiguration = [
[
'fallback' => 'The Mythical Animal is a Unicorn',
'title' => 'What are Mythical Animals?',
'text' => 'Mythical animals are creatures that dont exist',
'actions' => [
[
'text' => 'Find more about Unicorns',
'url' => 'https://en.wikipedia.org/wiki/Unicorn',
],
],
'fields' => [
[
'title' => 'Mythical Animal',
'value' => 'Unicorn',
'short' => true,
],
],
],
];
$slackNotification = (new SlackNotification)
->toHook('abc\123\xyz')
->withUsername('Newt Scamander')
->withIcon('unicorn_face')
->toChannel('#mythical_beasts')
->withTitle('Testing Slack Notification')
->withText('Just checking to make sure the notification goes through')
->unfurlLinks(false)
->unfurlMedia(false);
->withAttachments($slackAttachmentConfiguration)
->send();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.