insidieux/slack-api
最新稳定版本:1.4.2
Composer 安装命令:
composer require insidieux/slack-api
包简介
Simple Slack API client wih predefined methods
README 文档
README
| This project is very outdated and behind the current actual version of php, as well as the current version of the Slack API. We strongly DO NOT RECOMMEND you to use this library and we advise you to switch to one of the published packages from the official Slack documentation - https://api.slack.com/community#php |
|---|
A simple PHP package for making request to Slack API, focused on ease-of-use and elegant syntax.
Requirements
- PHP 5.5 or greater
- CURL extension for PHP
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 insidieux/slack-api
Usage
Create API client
$client = new \SlackApi\Client('your-token-here');
Make request
$client = new \SlackApi\Client('your-token-here'); $response = $client->request('module.method', ['argument' => 'value']); $response->toArray();
Or you can use predefined modules and methods
$client = new \SlackApi\Client('your-token-here'); $response = $client->users()->getList(); $response->toArray()
Predefined modules:
- [channels] (https://api.slack.com/methods#channels)
- [chat] (https://api.slack.com/methods#chat)
- [dnd] (https://api.slack.com/methods#dnd)
- [emoji] (https://api.slack.com/methods#emoji)
- [files] (https://api.slack.com/methods#files)
- [groups] (https://api.slack.com/methods#groups)
- [im] (https://api.slack.com/methods#im)
- [oauth] (https://api.slack.com/methods#oauth)
- [pins] (https://api.slack.com/methods#pins)
- [search] (https://api.slack.com/methods#search)
- [team] (https://api.slack.com/methods#team)
- [usergroups] (https://api.slack.com/methods#usergroups)
- [users] (https://api.slack.com/methods#users)
Message and attachment objects
Create message object
$client = new \SlackApi\Client('your-token-here'); $message = new \SlackApi\Models\Message($client);
or
$client = new \SlackApi\Client('your-token-here'); $message = $client->makeMessage();
Create new attachment from array
$data = [ 'fallback' => 'Some fallback' 'pretext' => 'Some pretext', 'text' => 'good', 'text' => 'Some text' ]; $attachment1 = new \SlackApi\Models\Attachment($data);
Or use set methods
$attachment2 = new \SlackApi\Models\Attachment; $attachment2->setText('Some text') ->setColor(\SlackApi\Models\Attachment::COLOR_GOOD) ->setFallback('Some fallback');
Add field to attachment
$field = new \SlackApi\Models\AttachmentField; $field->setShort(false) ->setTitle('Field title') ->setValue('Field value'); $attachment->addField($field);
Attach object to message
$message->attach($attachment);
Send message
$response = $message->send(); $response->toArray()
Author
统计信息
- 总下载量: 27.76k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 5
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-03-17