revolution / laravel-notification-chatwork
此包已废弃且不再维护。未建议替代包。
Laravel的Chatwork通知渠道。(v2)
2.1.0
2019-03-02 01:00 UTC
Requires
- php: >=7.1.3
- guzzlehttp/guzzle: ^6.0
- illuminate/notifications: ^5.5
- illuminate/support: ^5.5
Requires (Dev)
- mockery/mockery: ^1.0
- orchestra/database: ^3.5
- orchestra/testbench: ^3.5
- phpunit/phpunit: ^7.5
README
已结束
由于不再使用,已从packagist删除。您可以通过composer.json直接指定repositories来使用它,但如果有人想使用,则建议您进行分支并自行管理。
从原始版本的变化点
虽然已分支使用,但每次都需要在composer.json中设置repositories,因此作为单独的包进行注册。
- ChatWork API v2
- 按消息设置token。用于通过不同账户发布。
- PHP7.1以上
- 命名空间更改
composer require revolution/laravel-notification-chatwork
use Revolution\NotificationChannels\Chatwork\ChatworkMessage; return (new ChatworkMessage())->token('token') ->message('message');
此包使得使用Chatwork API通过Laravel 5.3发送Chatwork消息变得简单。
内容
安装
您可以通过composer安装此包
composer require e2kaneko/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'); } }
路由消息
您可以通过向roomId($roomId)方法提供接收者的room_id来发送通知,如上述示例所示,或者在您的可通知模型中添加routeNotificationForChatwork()方法
... /** * Route notifications for the Chatwork channel. * * @return int */ public function routeNotificationForChatwork() { return '99999999'; // Chatwork Room ID } ...
可用的消息方法
Message(ChatworkMessage)
roomId('roomId')
: (integer|string) Chatwork房间ID。to('accountId')
: (integer|string) .message('message')
: (string) Chat消息。
Information(ChatworkInformation)
roomId('roomId')
: (integer|string) Chatwork房间ID。informationTitle('title')
: (string) 信息框标题。informationMessage('message')
: (string) 信息框消息。
变更日志
请参阅CHANGELOG以获取有关最近更改的更多信息。
测试
$ composer test
安全
如果您发现任何安全相关的问题,请通过kaneko@e2info.com发送电子邮件,而不是使用问题跟踪器。
贡献
请参阅CONTRIBUTING以获取详细信息。
鸣谢
许可协议
MIT 许可协议(MIT)。有关更多信息,请参阅许可文件。