attendlabs / webhook
Webhook 通知驱动程序
2.4.0
2024-06-27 00:06 UTC
Requires
- php: ^7.2.5 || ^8.0
- guzzlehttp/guzzle: ^6.2 || ^7.0
- illuminate/notifications: ^6.0 || ^7.0 || ^8.0 || ^9.0 || ^10.0 || ^11.0
- illuminate/support: ^6.0 || ^7.0 || ^8.0 || ^9.0 || ^10.0 || ^11.0
Requires (Dev)
- mockery/mockery: ^1.3
- orchestra/testbench: ^4.0 || ^5.0 || ^6.0 || ^7.0 || ^8.0 || ^9.0
- phpunit/phpunit: ^9.0 || ^10.5
README
此包使用 Laravel 通知系统轻松发送 Webhook。
兼容性
内容
安装
您可以通过 composer 安装此包
composer require laravel-notification-channels/webhook
使用
现在您可以在通知中的 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('')
:接受可 JSON 编码的值作为 Webhook 体的内容。query('')
:接受要添加到请求中的查询字符串值的关联数组。userAgent('')
:接受 Webhook 用户代理的字符串值。header($name, $value)
:设置要随 POST Webhook 发送的自定义头信息。verify()
:启用 SSL 证书验证或提供 CA 套件的路径
变更日志
有关最近更改的更多信息,请参阅变更日志
测试
$ composer test
安全
如果您发现任何安全相关的问题,请通过电子邮件 atymicq@gmail.com 而不是使用问题跟踪器来报告。
贡献
有关详细信息,请参阅贡献指南
致谢
许可
MIT 许可证 (MIT)。有关更多信息,请参阅许可文件