From f94c60fabdec42952f5d5083557e807d1fad9f0b Mon Sep 17 00:00:00 2001 From: Chaim Date: Mon, 15 Jun 2020 15:52:11 +0800 Subject: [PATCH] =?UTF-8?q?-=20=E4=BC=98=E5=8C=96=E4=BC=81=E4=B8=9A?= =?UTF-8?q?=E5=BE=AE=E4=BF=A1=E6=9C=8D=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- composer.json | 3 ++- src/service/wechat/QyService.php | 27 ++++++++++++++++----------- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/composer.json b/composer.json index 7404d7f..67fec5f 100644 --- a/composer.json +++ b/composer.json @@ -43,7 +43,8 @@ "qiniu/php-sdk": "^7.2", "upyun/sdk": "^3.4", "netease/nos-php-sdk": "^1.0", - "aws/aws-sdk-php": "^3.142" + "aws/aws-sdk-php": "^3.142", + "liguangchun/qyweixin-grouprobot": "^1.0" }, "require-dev": { "symfony/var-dumper": "^4.2" diff --git a/src/service/wechat/QyService.php b/src/service/wechat/QyService.php index 57cbe56..823acda 100644 --- a/src/service/wechat/QyService.php +++ b/src/service/wechat/QyService.php @@ -16,6 +16,8 @@ namespace DtApp\ThinkLibrary\service\wechat; +use DtApp\Notice\QyWeiXin\QyWeXinException; +use DtApp\Notice\QyWeiXin\Send; use DtApp\ThinkLibrary\exception\DtaException; use DtApp\ThinkLibrary\Service; use DtApp\ThinkLibrary\service\curl\HttpService; @@ -50,16 +52,17 @@ class QyService extends Service * 发送文本消息 * @param string $content 消息内容 * @return bool - * @throws DtaException + * @throws DtaException|QyWeXinException */ public function text(string $content = '') { $this->msgType = 'text'; - return $this->sendMsg([ - 'text' => [ - 'content' => $content, - ], - ]); + if (empty($this->key)) throw new DtaException("请检查KEY"); + $config = [ + 'key' => $this->key + ]; + $qywx = new Send($config); + return $qywx->text($content); } /** @@ -67,15 +70,17 @@ class QyService extends Service * @param string $content 消息内容 * @return bool * @throws DtaException + * @throws QyWeXinException */ public function markdown(string $content = '') { $this->msgType = 'markdown'; - return $this->sendMsg([ - 'markdown' => [ - 'content' => $content, - ], - ]); + if (empty($this->key)) throw new DtaException("请检查KEY"); + $config = [ + 'key' => $this->key + ]; + $qywx = new Send($config); + return $qywx->text($content); } /**