dev-master
9999999-devPHP package for integrating with Slack API.
BSD-2-Clause
The Requires
- php >=5.3.0
- guzzle/http 3.9.2
The Development Requires
by RadosĆaw Karkut
PHP package for integrating with Slack API.
Package for integrating with Slack API., (*1)
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)
// 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... }
To manage channels You can call methods like in the examples below., (*5)
$client->channels()->create("channel.name");
$client->channels()->archive('#channel.name');
$client->channels()->getList();
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');
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);
I will work on this plugin to add new functionality. If you have any suggestions please log an issue on GitHub., (*8)
PHP package for integrating with Slack API.
BSD-2-Clause