rkarkut/slack-package
Composer 安装命令:
composer require rkarkut/slack-package
包简介
PHP package for integrating with Slack API.
README 文档
README
Package for integrating with Slack API.
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.
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.
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.
$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.
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.
$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.
// 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.
统计信息
- 总下载量: 9
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: BSD-2-Clause
- 更新时间: 2015-09-25