2017 © Pedro Peláez
 

library slack

An interface for interacting with Slack (slack.com). Their entire API is not yet implemented here, so far just sending messages to channels.

image

dmanetwork/slack

An interface for interacting with Slack (slack.com). Their entire API is not yet implemented here, so far just sending messages to channels.

  • Friday, February 26, 2016
  • by bobmajdakjr
  • Repository
  • 0 Watchers
  • 0 Stars
  • 32 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

dmanetwork/slack

Small connection to Slack (slack.com) for sending messages to channels via their API., (*1)

Install

Use Composer., (*2)

Simple Usage

Define your Slack options early on with the rest of your application configuration. The only option you MUST specify is the API access token, which you can generate from http://api.slack.com while you are logged in there., (*3)

Nether\Option::Set('slack-token','YOUR-SLACK-TOKEN');

Create an instance of the client to interact with the Slack API., (*4)

$slack = new DMA\Slack\Client;

Then you can send messages., (*5)

$slack->Send('Hello from our Slack enabled app.');

If you do not change any of the other options you should see a message from Optimus Prime in your #general channel., (*6)

Advanced Usage

More options at app config time...

These are all the options available to set at application config time., (*7)

Nether\Option::Set([
    'slack-token' => 'YOUR-SLACK-TOKEN',
    'slack-default-channel' => '#channel',
    'slack-default-name' => 'bot name of choice',
    'slack-default-icon' => 'url to public accessable image for chat icon',
    'slack-channels' => [ 'action-name' => 'channel', ... ]
]);

More options at instance time (overwrites prev options)...

These are all the options available to set at instance create time., (*8)

$slack = new DMA\Slack\Client([
    'DefaultChannel' => '#channel',
    'DefaultName' => 'bot name of choice',
    'DefaultIcon' => 'url to icon',
    'Token' => 'YOUR-SLACK-TOKEN'
]);

More options at message send time...

And these are all the options available to set at message send time., (*9)

$slack->Send('message here',[
    'Channel' => '#DifferentChannel',
    'Name' => 'Different Bot Name',
    'Icon' => 'url to different icon'
]);

If all you want to do is send to a different channel or user than the default., (*10)

$slack->SendToChannel($chan,$msg);

Or send to a different channel as specified by any actions configured., (*11)

// send user-add action notifications to the team.
$slack->SendToChannel('--user-add',$msg);

Sending an API request we have not wrapped...

$slack->SendRequest(string method, array args);

The method name is the final part of the API url specified in the Slack documentation. The argument array then would be an associative array where the keys are the names of the parameters as Slack says, with the values you want to send., (*12)

Copyright

This software is Copyright (c) 2014 Dream Machine Association, LLC. See the bundled LICENSE file (BSD-2-Clause) for more information., (*13)

The Versions

26/02 2016

dev-master

9999999-dev

An interface for interacting with Slack (slack.com). Their entire API is not yet implemented here, so far just sending messages to channels.

  Sources   Download

BSD-2-Clause

The Requires

 

php slack

26/02 2016

v2.0.0

2.0.0.0

An interface for interacting with Slack (slack.com). Their entire API is not yet implemented here, so far just sending messages to channels.

  Sources   Download

BSD-2-Clause

The Requires

 

php slack

09/03 2015

v1.0.0

1.0.0.0

An interface for interacting with Slack (slack.com). Their entire API is not yet implemented here, so far just sending messages to channels.

  Sources   Download

BSD-2-Clause

The Requires

 

php slack