minkbear / webhook
Webhook 通知驱动
1.2.0
2018-05-07 18:04 UTC
Requires
- php: >=5.6.4
- guzzlehttp/guzzle: ~6.0
- illuminate/notifications: 5.3.*|5.4.*|5.5.*|5.6.*
- illuminate/support: 5.1.*|5.2.*|5.3.*|5.4.*|5.5.*|5.6.*
Requires (Dev)
- mockery/mockery: ^0.9.5
- orchestra/database: 3.3.x-dev|^3.5.0
- orchestra/testbench: 3.3.x-dev|^3.5.0
- phpunit/phpunit: 4.*|~6.0
README
此包使您能够通过 Laravel 5.3 通知系统轻松发送 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'); } }
为了使您的通知知道应接收 Webhook 数据的 URL,将 routeNotificationForWebhook
方法添加到您的可通知模型中。
此方法需要返回通知 Webhook 将接收 POST 请求的 URL。
public function routeNotificationForWebhook() { return 'http://requestb.in/1234x'; }
可用方法
data('')
:接受用于 Webhook 体的可 JSON 编码值。userAgent('')
:接受用于 Webhook 用户代理的字符串值。header($name, $value)
:设置要随 POST Webhook 一起发送的附加头信息。
变更日志
有关最近更改的更多信息,请参阅变更日志。
测试
$ composer test
安全性
如果您发现任何与安全性相关的问题,请通过电子邮件 m.pociot@gmail.com 而不是使用问题跟踪器。
贡献
有关详细信息,请参阅贡献。
鸣谢
许可
MIT 许可证 (MIT)。有关更多信息,请参阅许可证文件。