佳境国 / lark-notification-channel
Lark 通知驱动程序
v1.0.0
2021-11-02 07:34 UTC
Requires
- php: ^7.2.5 || ^8.0
- guzzlehttp/guzzle: ^6.2 || ^7.0
- illuminate/notifications: ^6.0 || ^7.0 || ^8.0
- illuminate/support: ^6.0 || ^7.0 || ^8.0
Requires (Dev)
- mockery/mockery: ^1.3
- orchestra/testbench: ^4.0 || ^5.0 || ^6.0
- phpunit/phpunit: ^9.0
This package is auto-updated.
Last update: 2024-09-08 09:14:50 UTC
README
此包通过 Laravel 通知系统发送 Lark 变得更加容易。支持 5.5+、6.x、7.x 和 8.x。
内容
安装
您可以通过 composer 安装此包
composer require yajianguo/lark-notification-channel
使用方法
现在您可以在通知的 via() 方法中使用此通道
use NotificationChannels\Lark\LarkChannel; use NotificationChannels\Lark\LarkMessage; use Illuminate\Notifications\Notification; class ProjectCreated extends Notification { public function via($notifiable) { return [LarkChannel::class]; } public function toLark($notifiable) { return LarkMessage::create() ->url('https://open.feishu.cn/open-apis/bot/v2/hook/selfPath') ->data([ 'payload' => [ 'lark' => 'data' ] ]) ->userAgent("Custom-User-Agent") ->header('X-Custom', 'Custom-Header'); } }
为了让您的通知知道哪个 URL 应该接收 Lark 数据,请将 routeNotificationForLark 方法添加到您的 Notifiable 模型中。
URL 或模型 POST 请求。
public function routeNotificationForLark() { return 'http://requestb.in/1234x'; }
可用方法
url(''):接受一个字符串值作为 Lark URL。data(''):接受一个可 JSON 编码的值作为 Lark 主体。query(''):接受一个关联数组,用于添加到请求的查询字符串中。userAgent(''):接受一个字符串值作为 Lark 用户代理。header($name, $value):设置在 POST Lark 中发送的附加标题。
变更日志
请参阅 CHANGELOG 以获取最近更改的更多信息。
安全性
如果您发现任何安全相关的问题,请通过电子邮件 a@a.com 报告,而不是使用问题跟踪器。
贡献
有关详细信息,请参阅 CONTRIBUTING。
鸣谢
许可
MIT 许可证 (MIT)。有关更多信息,请参阅 许可文件。