ryukyuinteractive / laravel-chatwork-notifications
此包已废弃,不再维护。没有建议的替代包。
Laravel的Chatwork通知通道。(v2)
1.1.0
2020-04-01 02:39 UTC
Requires
- php: >=5.6.4
- guzzlehttp/guzzle: ~6.0
- illuminate/notifications: ^5.3
- illuminate/support: ^5.1|^5.2|^5.3
Requires (Dev)
- mockery/mockery: ^0.9.5
- orchestra/database: 3.3.x-dev
- orchestra/testbench: 3.3.x-dev
- phpunit/phpunit: 4.*
This package is auto-updated.
Last update: 2024-08-29 05:30:52 UTC
README
此包简化了使用Laravel 5.3和Chatwork API发送Chatwork消息的过程。
内容
安装
您可以通过composer安装此包
composer require ryukyuinteractive/laravel-chatwork-notifications
您必须安装服务提供者
// config/app.php 'providers' => [ ... NotificationChannels\Chatwork\ChatworkServiceProvider::class, ],
配置
配置您的凭证
// config/services.php ... 'chatwork' => [ 'api_token' => env('CHATWORK_API_TOKEN'), ], ...
使用
现在您可以在Notification类中的via()方法中使用此通道。
<?php namespace App\Notifications; use Illuminate\Bus\Queueable; use Illuminate\Notifications\Notification; use NotificationChannels\Chatwork\ChatworkMessage; use NotificationChannels\Chatwork\ChatworkChannel; class ChatworkPosted extends Notification { use Queueable; public function __construct() { } public function via($notifiable) { return [ChatworkChannel::class]; } public function toChatwork($notifiable) { return (new ChatworkMessage()) ->message('message'); } }
或者
<?php namespace App\Notifications; use Illuminate\Bus\Queueable; use Illuminate\Notifications\Notification; use NotificationChannels\Chatwork\ChatworkInformation; use NotificationChannels\Chatwork\ChatworkChannel; class ChatworkPosted extends Notification { use Queueable; public function __construct() { } public function via($notifiable) { return [ChatworkChannel::class]; } public function toChatwork($notifiable) { return (new ChatworkInformation()) ->informationTitle('InformationTitle') ->informationMessage('InformationMessage'); } }
路由消息
您可以通过将接收者的room_id提供给roomId($roomId)方法来发送通知,如上述示例所示,或者在你的notifiable模型中添加routeNotificationForChatwork()方法。
... /** * Route notifications for the Chatwork channel. * * @return int */ public function routeNotificationForChatwork() { return '99999999'; // Chatwork Room ID } ...
可用的消息方法
消息(ChatworkMessage)
roomId('roomId'): (integer|string) Chatwork房间ID。to('accountId'): (integer|string) .message('message'): (string) Chat消息。
信息(ChatworkInformation)
roomId('roomId'): (integer|string) Chatwork房间ID。informationTitle('title'): (string) 信息框标题。informationMessage('message'): (string) 信息框消息。
变更日志
请参阅变更日志了解最近的更改。
测试
$ composer test
安全
如果您发现任何安全问题,请通过kaneko@e2info.com发送电子邮件,而不是使用问题跟踪器。
贡献
请参阅贡献指南以获取详细信息。
鸣谢
许可证
MIT许可证(MIT)。有关更多信息,请参阅许可证文件。