displayce/slack-bundle

此包提供了与 Slack API 库的集成,允许您在 Symfony 项目中与 Slack API 进行交互

维护者

详细信息

github.com/displayce/slackBundle

来源

安装: 3,074

依赖者: 0

建议者: 0

安全: 0

星标: 0

关注者: 1

分支: 29

类型:symfony-bundle

0.23.0 2020-08-23 16:22 UTC

README

Symfony 扩展,通过提供易于使用的服务和配置,将 Slack API 客户端集成到项目中。

如果您想从命令行访问 Slack Web API,请考虑安装slack-cli 包。

Latest Version

快速示例

以下是如何使用 API 的 chat.postMessage 方法向 Slack 中的一个频道发送消息的示例

<?php
// Acme\DemoBundle\Controller\MySlackController

public function sendAction()
{
    $payload = new ChatPostMessagePayload();
    $payload->setChannel('#general');   // Channel names must begin with a hash-sign '#'
    $payload->setText('Hello world!');  // also supports Slack formatting
    $payload->setUsername('acme');      // can be anything you want
    $payload->setIconEmoji('birthday'); // check out emoji.list-payload for a list of available emojis

    $response = $this->get('cl_slack.api_client')->send($payload);

    // display the Slack channel ID on which the message was posted
    echo $response->getChannel(); // would return something like 'C01234567'

    // display the Slack timestamp on which the message was posted (note: NON-unix timestamp!)
    echo $response->getTimestamp(); // would return something like '1407190762.000000'
}

在 Slack 中,这将在 #general 频道中得到类似的结果:发送到 Slack 的消息示例

更多示例可以在使用文档中找到。

文档

关于如何访问每个 API 方法的详细文档可以在集成此扩展的包的文档中找到: Slack API 库

感谢

  • @fieg,为将 Slack 集成到我们的项目中提供了初步想法。
  • Slack 的团队,因为他们制作了一个出色的产品并提供了清晰的文档。

贡献

如果您想为此包做出贡献,请查看贡献文档