healthengine / laravel-webhook-channel
v2.2.0
2023-02-13 07:28 UTC
Requires
- php: ~8.0.0 || ~8.1.0
- guzzlehttp/guzzle: ^7.0
- illuminate/notifications: ^8.0 || ^9.0
- illuminate/support: ^8.0 || ^9.0
Requires (Dev)
- mockery/mockery: ^1.5
- orchestra/testbench: ^6.23 || ^7.22
- phpunit/phpunit: ^9.4
Replaces
This package is auto-updated.
Last update: 2023-09-19 17:03:30 UTC
README
警告
此包不再维护。
请使用 laravel-notification-channels/webhook 代替。
Laravel 的 Webhook 通知通道
此包使得使用 Laravel 5.5 通知系统发送 Webhook 变得容易。
内容
安装
您可以通过 composer 安装此包
composer require healthengine/laravel-webhook-channel
使用方法
现在您可以在通知中的 via()
方法中使用此通道
use NotificationChannels\Webhook\WebhookChannel; use NotificationChannels\Webhook\WebhookMessage; use Illuminate\Notifications\Notification; class ProjectCreated extends Notification { public function via($notifiable) { return [WebhookChannel::class]; } public function toWebhook($notifiable) { return WebhookMessage::create() ->data([ 'payload' => [ 'webhook' => 'data' ] ]) ->userAgent("Custom-User-Agent") ->header('X-Custom', 'Custom-Header'); } }
为了使通知知道哪个 URL 应该接收 Webhook 数据,将 routeNotificationForWebhook
方法添加到您的可通知模型中。
此方法需要返回通知 Webhook 将接收 POST 请求的 URL。
public function routeNotificationForWebhook() { return 'http://requestb.in/1234x'; }
可用方法
data('')
: 接受用于 Webhook 体的可 JSON 编码值。userAgent('')
: 接受用于 Webhook 用户代理的字符串值。header($name, $value)
: 为 POST Webhook 设置额外的头部。
变更日志
请查看 CHANGELOG 以获取更多关于最近更改的信息。
测试
$ composer test
安全
如果您发现任何与安全相关的问题,请通过电子邮件 m.pociot@gmail.com 而不是使用问题跟踪器。
贡献
请参阅 CONTRIBUTING 以获取详细信息。
鸣谢
许可
MIT 许可证 (MIT)。请参阅 许可文件 以获取更多信息。