linxlad / zephlack
该包最新版本(dev-master)没有提供许可证信息。
用 Zephir 编写的 Slack 消息扩展。
dev-master
2015-01-04 02:24 UTC
Requires (Dev)
- phpunit/phpunit: 4.3.*
This package is not auto-updated.
Last update: 2024-09-28 16:31:08 UTC
README
用 Zephir 编写的 Slack 消息扩展。
Slack 是一个团队沟通平台:一切都在一个地方,立即可搜索,无论你走到哪里都可以访问。你可以在这里了解更多关于 Slack 的信息。
安装
预构建扩展
从这里下载最新扩展并将其放置在以下目录:####Ubuntu /usr/lib/php5/20.../zephlack.so
####CentOS /usr/lib64/php/modules/zephlack.so
将扩展添加到您的 PHP 配置中
extension=zephlack.so
#####自行构建扩展
(此选项需要 Zephir 安装。安装说明可以在这里找到)
git clone --depth=1 --branch=master https://github.com/linxlad/zephlack.git
cd zephlack
zephir build
将扩展添加到您的 PHP 配置中
extension=zephlack.so
最后,重新启动您的 web 服务器。
使用方法
简单
$client = new Zephlack\Client('team', 'token'); $message = new Zephlack\Message\Message('This year you are on the good list'); $message->setChannel('#channel'); $message->setIconEmoji(':santa:'); $message->setUsername('Mr Claus'); $client->setDebug(false); /* WIll return bool or if debug is enabled will return the payload and response */ $client->notify($message);
带有附件
$client = new Zephlack\Client('team', 'token'); $message = new Zephlack\Message\Message('This year you are on the good list'); $attachment = new Zephlack\Message\MessageAttachment(); $field = new Zephlack\Message\MessageField(); $field ->setTitle('foo') ->setValue('bar'); $attachment->addField($field); $message->addAttachment($attachment); $message->setChannel('#channel'); $message->setIconEmoji(':santa:'); $message->setUsername('Mr Claus'); $client->notify($message);
消息
如果你的消息包含 @username 并希望他收到通知,请添加 $message->enableLinkNames(true)
致谢
我想感谢
Polem,他为基于此的 slack-notifier 做了大量工作。这是一个优秀的 PHP Slack 消息包,可以在slack-notifier找到。
Nirlah,他为节省了我数小时的工作时间的 http 工具。这同样是一个基于 Zephir 的优秀包,可以在Toolbelt找到。