auroraari / discord-webhooks
此包已被废弃且不再维护。未建议替代包。
一个轻量级的 Discord Webhooks 使用封装器
v1.0
2016-10-28 17:33 UTC
Requires
- php: ^5.3
- ext-curl: ^0.0.0
This package is not auto-updated.
Last update: 2018-11-29 21:34:49 UTC
README
一个轻量级的封装器,用于与 Discord Webhooks 交互!
入门指南
此封装器通过使用 Composer 安装。您还需要安装(至少)PHP 5.3,以及 ext-curl。此封装器尚未在 HHVM 上进行测试,但没有任何理由它不能工作!
- 运行
composer require auroraari/discord-webhooks
安装最新版本。 - 在文件顶部包含 Composer 自动加载文件
include __DIR__.'/vendor/autoload.php';
- 享受吧!
在 Discord 中设置 Webhook
目前这仅适用于 Discord 的公共测试构建,可以在以下位置找到:这里为 Windows 和 这里为 Mac。
-
点击“创建 Webhook”按钮并填写表格。您设置的“名称”字段和头像是默认值,可以在本封装器中覆盖,但 选择的渠道不能通过封装器更改。 您需要为每个要发布的渠道设置一个单独的 URL。
-
复制“Webhook URL”,并在初始化类时使用它。
-
享受吧!
示例
<?php include __DIR__.'/vendor/autoload.php'; use \DiscordWebhooks\Client as DiscordWebhook; $discord = new DiscordWebhook('URL-FROM-DISCORD'); $discord->name('AuroraAri'); // Optionally, provide a name that the message will be sent from. If not set, uses the name set in Discord. $discord->avatar('http://i.imgur.com/RNYMCQp.png'); // Optionally, a URL for the user's avatar. If not set, uses the avatar set in Discord. $discord->message('Hi, Discord!'); // Optionally, set the message to be sent here. If not set, uses the message in $this->send(). $discord->send('Hi again, Discord!'); // If the message wasn't set in $this->message, it must be set here. This method sends the message.