oanhnn / laravel-webhook-notification
集成 Webhook 通知到 Laravel 5.5+
v0.1.0
2018-07-06 07:54 UTC
Requires
- php: ^7.1.3
- guzzlehttp/guzzle: ^6.3
- illuminate/notifications: ^5.5
- illuminate/support: ^5.5
- psr/http-message: ^1.0
Requires (Dev)
- mockery/mockery: ^0.9
- orchestra/testbench: ^3.5
- phpunit/phpunit: ~6.1|~7.0
- squizlabs/php_codesniffer: ^3.0
This package is auto-updated.
Last update: 2024-09-22 22:04:13 UTC
README
在 Laravel 5.5+ 应用中轻松发送 Webhook 通知
要求
- php >=7.1.3
- Laravel 5.5+
安装
首先通过 Composer 拉取此包。
$ composer require oanhnn/laravel-webhook-notification
使用
实现 webhook 可通知
class User extends Authenticatable implements WebhookNotifiable { use Notifiable; /** * @return string */ public function getSigningKey(): string { return $this->api_key; } /** * @return string */ public function getWebhookUrl(): string { return $this->webhook_url; } }
在通知类中,
class ProjectCreated extends Notification { /** * @return array */ public function via($notifiable) { return [WebhookChannel::class]; } /** * @return array|WebhookMessage */ public function toWebhook($notifiable) { return WebhookMessage::create() ->data([ 'payload' => [ 'foo' => 'bar' ] ]) ->userAgent("Custom-User-Agent") ->header('X-Custom', 'Custom-Header'); } }
更多信息请参考 Laravel 文档
更新日志
查看所有更新日志 CHANGELOG
测试
$ git clone git@github.com/oanhnn/laravel-webhook-notification.git /path
$ cd /path
$ composer install
$ composer phpunit
贡献
请参阅 CONTRIBUTING 以获取详细信息。
安全
如果您发现任何安全问题,请通过电子邮件发送给 Oanh Nguyen,而不是使用问题跟踪器。
致谢
许可
本项目遵循 MIT 许可协议发布。
版权 © 2018 Oanh Nguyen.