2017 © Pedro Peláez
 

library slack-hooker

simple slack webhook

image

bc/slack-hooker

simple slack webhook

  • Monday, April 25, 2016
  • by theinpu
  • Repository
  • 1 Watchers
  • 0 Stars
  • 980 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Simple Slack Webhook Sender

Install

composer require bc/slack-hooker:*, (*1)

Usage


require_once 'vendor/autoload.php'; //instantiate bc\Slack\SlackHooker with webhook url $hooker = new bc\Slack\SlackHooker('WEBHOOK_URL'); //build message $messageBuilder = new bc\Slack\MessageBuilder(); $messageBuilder ->setText("Simpe text") ->setUserName("Bot") ->setChannel('#random') ->setIconEmoji(':cow:'); //build attachment $attachBuilder = new bc\Slack\AttachmentBuilder(); $attachBuilder ->setFallback("fallback text") ->setText("attachment text") ->setPreText("pre text") ->setColor("#369") ->setAuthorName("Author") ->setAuthorLink("") ->setAuthorIcon("") ->setTitle("title") ->setTitleLink("") ->addField('field1', 'value') ->addField('field2', 'value') ->addField('field3', 'value', false) ->setImageUrl("") ->setThumbUrl(""); //add attachment $messageBuilder->attach($attachBuilder->build()); //build and add another attachment $attachment = (new bc\Slack\AttachmentBuilder()) ->setFallback("fallback") ->setText("second attachment") ->build(); $messageBuilder->attach($attachment); $message = $messageBuilder->build(); //send message. returns \Psr\Http\Message\ResponseInterface $response = $hooker->sendMessage($message);

The Versions

25/04 2016

dev-master

9999999-dev

simple slack webhook

  Sources   Download

MIT

The Requires

 

The Development Requires