komujohn / google-chat-notifier
Symfony Google Chat Notifier 桥接器
v5.2.4
2021-01-15 08:35 UTC
Requires
- php: >=7.2.5
- symfony/http-client: ^4.3|^5.0
- symfony/notifier: ~5.2.2
This package is not auto-updated.
Last update: 2024-09-23 22:24:47 UTC
README
为 Symfony Notifier 提供 Google Chat 集成。允许在通知时设置线程键。
DSN 示例
GOOGLE_CHAT_DSN=googlechat://ACCESS_KEY:ACCESS_TOKEN@default/SPACE?thread_key=THREAD_KEY
其中
ACCESS_KEY
是您的 Google Chat 访问密钥ACCESS_TOKEN
是您的 Google Chat 访问令牌SPACE
是 Google Chat 空间THREAD_KEY
是将消息分组到单个消息线程的 Google Chat 消息线程(可选)
代码示例
<?php
namespace App\Service;
use Symfony\Component\Notifier\Bridge\GoogleChat\ThreadNotification;
use Symfony\Component\Notifier\Notification\Notification;
use Symfony\Component\Notifier\NotifierInterface;
use Symfony\Component\Notifier\Recipient\NoRecipient;
class NotificationHelper {
private NotifierInterface $notifier;
public function __construct( NotifierInterface $notifier ) {
$this->notifier = $notifier;
}
public function sendNotification($subject,$message,$thread_key='general5'){
$notification = (new ThreadNotification())
->subject($subject)
->content($message)
->thread($thread_key)
->importance(Notification::IMPORTANCE_HIGH);
$this->notifier->send($notification, new NoRecipient());
}
}
资源
- 贡献
- 报告问题 和 发送拉取请求 在 主 Symfony 仓库