2017 © Pedro PelĂĄez
 

library slack-package

PHP package for integrating with Slack API.

image

rkarkut/slack-package

PHP package for integrating with Slack API.

  • Friday, September 25, 2015
  • by slummer87
  • Repository
  • 1 Watchers
  • 0 Stars
  • 4 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Slack API package

Package for integrating with Slack API., (*1)

Requirements

  • PHP 5.3 or higher
  • Curl

Installation

You can install the package using the Composer package manager. You can install it by running this command in your project root., (*2)

composer require rkarkut/slack-package:master-dev

Then create an Application in your Slack account for the package to use. You will need the Client ID and Client Secret to prepare authorization script., (*3)

Basic USage

Create client instance and test API connection

// create instance
$client = new \Rkarkut\Slack\Client();

if ($client->api()->test()) {
    // Api is working...
}

To test Your token You can call your client instance like in the example below., (*4)

$client->setToken('your.token');

if ($client->auth()->test()) {
    // Auth is OK...
}

Managing channels

To manage channels You can call methods like in the examples below., (*5)

Creating a channel

$client->channels()->create("channel.name");

Archiving a channel

$client->channels()->archive('#channel.name');

Getting list of channels

$client->channels()->getList();

Posting messages

To post a message to any channels You can call methods like in the examples below., (*6)

$client->chat()->postMessage('post.message', 'name.of.bot');

Integrating the package to authorize Your application

To authorize any user with the Application you can use the package like in the example below., (*7)

// creating client instance
$client = new \Rkarkut\Slack\Client();

// put application client ID and secret
$clientId = 'your.client.id';
$clientSecret = 'client.secret';

// get authorization code from the Slack
$code = $_GET['code'];

// optional parameter
$redirectUrl = null;

// authorize
$result = $client->oauth($clientId, $clientSecret)->access($code, $redirectUrl);

Conclusion

I will work on this plugin to add new functionality. If you have any suggestions please log an issue on GitHub., (*8)

The Versions

25/09 2015

dev-master

9999999-dev

PHP package for integrating with Slack API.

  Sources   Download

BSD-2-Clause

The Requires

 

The Development Requires

by RadosƂaw Karkut