ccoeder/laravel-notification-webhook
Composer 安装命令:
composer require ccoeder/laravel-notification-webhook
包简介
Webhook Notifications driver
README 文档
README
This package makes it easy to send webhooks using the Laravel notification system.
This is an another fork from miladnouri/laravel-notification-webhook because I need to use with on-demand notifications so I added support for that.
Contents
Installation
You can install the package via composer:
composer require ccoeder/laravel-notification-webhook
Usage
Now you can use the channel in your via() method inside the notification:
use NotificationChannels\Webhook\WebhookMessage; use Illuminate\Notifications\Notification; class ProjectCreated extends Notification { public function via($notifiable) { return ['webhook']; } public function toWebhook($notifiable) { return WebhookMessage::create() ->data([ 'payload' => [ 'webhook' => 'data' ] ]) ->userAgent("Custom-User-Agent") ->header('X-Custom', 'Custom-Header'); } }
In order to let your Notification know which URL should receive the Webhook data, add the routeNotificationForWebhook method to your Notifiable model.
This method needs to return the URL where the notification Webhook will receive a POST request.
public function routeNotificationForWebhook() { return 'http://myrequest.com/abcd'; }
Available methods
data(''): Accepts a JSON-encodable value for the Webhook body.userAgent(''): Accepts a string value for the Webhook user agent.header($name, $value): Sets additional headers to send with the POST Webhook.
Changelog
Please see CHANGELOG for more information what has changed recently.
Testing
$ composer test
License
The MIT License (MIT). Please see License File for more information.
统计信息
- 总下载量: 5
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-08-19