enniel / laravel-vk-notification-channel
VK 通知驱动
v0.0.2
2016-10-25 08:52 UTC
Requires
- php: >=5.5.9
- atehnix/vk-client: ~1.0.0
- illuminate/notifications: ~5.3
- illuminate/support: ~5.1
Requires (Dev)
- friendsofphp/php-cs-fixer: ~1.12.2
This package is auto-updated.
Last update: 2024-09-06 03:59:17 UTC
README
此包简化了使用 Laravel 5.3 通过 vk.com 发送通知的过程。
内容
安装
您可以通过 composer 安装此包
composer require enniel/laravel-vk-notification-channel
使用
现在您可以在通知中的 via()
方法内使用此通道
use NotificationChannels\Vk\VkChannel; use NotificationChannels\Vk\VkMessage; use Illuminate\Notifications\Notification; class ExampleNotification extends Notification { public function via($notifiable) { return [VkChannel::class]; } public function toVkontakte($notifiable) { return (new VkMessage()) ->message('message text') ->token('some_token'); } }
为了让您的通知知道向谁发送消息,您必须在通知模型中添加 routeNotificationForVkontakte
方法,该方法返回类似 ['user_id', 1] 的数组。
可用的消息方法
user()
: 用户 ID(默认为当前用户)。接受参数user_id
。random()
: 唯一标识符,用于避免重复发送消息。接受参数random_id
。peer()
: 目标 ID。接受参数peer_id
。domain()
: 用户简短地址(例如,illarionov
)。接受参数domain_id
。chat()
: 与消息相关的对话 ID。接受参数chat_id
。users()
: 消息接收者的 ID(如果需要开始新对话)。接受参数user_ids
。message()
: 发送者的身份。接受参数message
。lat()
: 检入的地理纬度,以度为单位(从 -90 到 90)。接受参数lat
。long()
: 检入的地理经度,以度为单位(从 -180 到 180)。接受参数long
。attachment()
: 消息中附加的对象列表。接受参数attachment
。forwarded()
: 转发消息的 ID。接受参数forward_messages
。sticker()
: 贴纸 ID。接受参数sticker_id
。notification()
:1
或true
如果消息是通知(社区消息)。接受参数notification
。token()
: 访问令牌。传递参数access_token
。更多信息请参阅 授权 和 获取令牌。to()
: 接收者。接受数组,如 ['user_id', 1],其中第一个值对应以下之一:peer_id, user_id, domain, chat_id 或 user_ids。
有关参数的更多信息,请参阅 messages.send。
测试
$ composer test
鸣谢
许可
MIT 许可证(MIT)。有关更多信息,请参阅 许可文件。