2017 © Pedro Peláez
 

library slack-client

A basic Slack client library providing simple posting to Slack channels using the webhook API.

image

markenwerk/slack-client

A basic Slack client library providing simple posting to Slack channels using the webhook API.

  • Monday, August 8, 2016
  • by bonscho
  • Repository
  • 1 Watchers
  • 0 Stars
  • 176 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 5 Versions
  • 14 % Grown

The README.md

PHP Slack Client

Build Status Test Coverage Dependency Status SensioLabs Insight Code Climate Latest Stable Version Total Downloads License, (*1)

A basic Slack client library providing simple posting to Slack channels using the webhook API., (*2)

Installation

```{json} { "require": { "markenwerk/slack-client": "~2.0" } }, (*3)


## Usage ### Autoloading and namesapce ```{php} require_once('path/to/vendor/autoload.php');

Posting to a channel or member

The following example will post to a Slack channel or member looking like this:, (*4)

Slack Example Post, (*5)

Setup the API client

```{php} use Markenwerk\SlackClient\SlackClient;, (*6)

$client = new SlackClient(); $client ->setSubdomainName('markenwerk') ->setToken('') ->setUsername('PHP SlackClient');, (*7)


#### Setup a Slack message with attachments ```{php} use Markenwerk\SlackClient\SlackAttachment; use Markenwerk\SlackClient\SlackAttachmentField; use Markenwerk\SlackClient\SlackMessage; $message = new SlackMessage(); $message ->setText('A basic Slack client library providing simple posting to Slack channels using the webhook API.') ->setIconUrl('https://avatars2.githubusercontent.com/u/5921253?v=3&s=200') ->setUnfurlLinks(true) ->setUnfurlMedia(true); $attachment = new SlackAttachment(); $attachment ->setText('A basic Slack client library providing simple posting to Slack channels using the webhook API.') ->setPretext('A basic Slack client library.') ->setFallback('A basic Slack client library providing simple posting to Slack channels using the webhook API.') ->setColor(SlackAttachment::COLOR_WARNING); $shortAttachmentField = new SlackAttachmentField(); $shortAttachmentField ->setTitle('Short field') ->setValue('Some chars') ->setShort(true); $anotherShortAttachmentField = new SlackAttachmentField(); $anotherShortAttachmentField ->setTitle('Short field') ->setValue('Some chars') ->setShort(true); $attachmentField = new SlackAttachmentField(); $attachmentField ->setTitle('Regular field') ->setValue('Some more chars') ->setShort(false); $anotherAttachmentField = new SlackAttachmentField(); $anotherAttachmentField ->setTitle('Regular field') ->setValue('Some more chars') ->setShort(false); $attachment ->addField($shortAttachmentField) ->addField($anotherShortAttachmentField) ->addField($attachmentField) ->addField($anotherAttachmentField); $message->addAttachment($attachment);

Post to a channel

```{php} $client->postToChannel('#channel', $message);, (*8)


#### Post to a member ```{php} $client->postToMember('@member', $message);

Exception handling

PHP Basic HTTP Client provides different exceptions – also provided by the PHP Common Exceptions project – for proper handling.
You can find more information about PHP Common Exceptions at Github., (*9)

Exceptions to be expected

In general you should expect that any setter method could thrown an \InvalidArgumentException. The following exceptions could get thrown while using PHP Slack Client., (*10)

  • Markenwerk\CommonException\ParserException\StringifyException on posting to Slack
  • Markenwerk\CommonException\NetworkException\UnexpectedResponseException on posting to Slack
  • Markenwerk\CommonException\NetworkException\ConnectionTimeoutException on posting to Slack
  • Markenwerk\CommonException\NetworkException\CurlException on posting to Slack

Contribution

Contributing to our projects is always very appreciated.
But: please follow the contribution guidelines written down in the CONTRIBUTING.md document., (*11)

License

PHP Slack Client is under the MIT license., (*12)

The Versions

08/08 2016

dev-master

9999999-dev http://markenwerk.net/

A basic Slack client library providing simple posting to Slack channels using the webhook API.

  Sources   Download

MIT

The Requires

 

The Development Requires

api slack

15/07 2016

2.0.1

2.0.1.0 http://markenwerk.net/

A basic Slack client library providing simple posting to Slack channels using the webhook API.

  Sources   Download

MIT

The Requires

 

The Development Requires

api slack

11/07 2016

2.0.0

2.0.0.0 http://markenwerk.net/

A basic Slack client library providing simple posting to Slack channels using the webhook API.

  Sources   Download

MIT

The Requires

 

The Development Requires

api slack

03/05 2016

1.0.0

1.0.0.0 http://markenwerk.net/

A basic Slack client library providing simple posting to Slack channels using the webhook API.

  Sources   Download

MIT

The Requires

 

The Development Requires

api slack

02/05 2016

0.0.1

0.0.1.0 http://markenwerk.net/

A basic Slack client library providing simple posting to Slack channels using the webhook API.

  Sources   Download

MIT

The Requires

 

The Development Requires

api slack