nhalstead/php-facilitator

触发 Webhooks 将数据发布到 PHP 中的通道。这将与 Slack、Discord 以及其他使用 WebHooks 的系统兼容。

v1.0 2018-08-29 04:43 UTC

This package is auto-updated.

Last update: 2024-09-05 05:10:54 UTC


README

使用基础包,您可以轻松地将请求发布到 Slack、Discord 以及其他具有 WebHook 终端的服 务!

这是一个 PHP 包,因此它符合 PSR4 规范,并且可以与或无需 composer 使用。

依赖(除了 CURL 外)。

系统甚至已准备好添加您自己的自定义 Webhook 终端。

支持的服务

安装

您可以通过 composer 安装此包

composer require nhalstead/php-facilitator

或者您可以从 GitHub 克隆代码

git clone https://github.com/nhalstead/php-facilitator.git

如何使用

使用 Composer 载入包

```php
>require_once("../vendor/autoload.php"); // Composer Method, Loading by PSR4
>use nhalstead\Facilitator\Facilitator;
>```

这将向指定事件上指定的频道发送负载。

use nhalstead\Facilitator\Facilitator;
use nhalstead\Facilitator\Endpoints\DiscordWebhook;

// Create new Queue
$queue = new Facilitator();

// Make new Event
$newEvent = new DiscordWebhook("[DISCORD WEBHOOK URL]");
$newEvent->username("John");
$newEvent->avatar("https://png.icons8.com/clouds/50/000000/megaphone.png");
$newEvent->message("Hello");


// Add and Send Events in Queue
$queue->addEvent($newEvent);
$queue->sendEvents();

更多示例,请参阅 /examples 文件夹。

贡献者