From dd07e354aac860c37cb65df59778e6f2f038b621 Mon Sep 17 00:00:00 2001 From: Anyon Date: Sat, 24 Mar 2018 13:31:45 +0800 Subject: [PATCH] =?UTF-8?q?[=E6=9B=B4=E6=96=B0]=E8=B0=83=E6=95=B4=E5=85=AC?= =?UTF-8?q?=E4=BC=97=E5=8F=B7=E6=B6=88=E6=81=AF=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/wechat/controller/api/Push.php | 27 ++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/application/wechat/controller/api/Push.php b/application/wechat/controller/api/Push.php index d85375aa8..89d6262f7 100644 --- a/application/wechat/controller/api/Push.php +++ b/application/wechat/controller/api/Push.php @@ -188,7 +188,7 @@ class Push } switch ($info['type']) { case 'customservice': - return $this->sendMessage('text', ['content' => $info['content']]); + return $this->sendMessage('customservice', ['content' => $info['content']]); case 'keys': $content = empty($info['content']) ? $info['name'] : $info['content']; return $this->keys("wechat_keys#keys#{$content}"); @@ -251,9 +251,28 @@ class Push { $msgData = ['touser' => $this->openid, 'msgtype' => $type, "{$type}" => $data]; switch (strtolower(sysconf('wechat_type'))) { - case 'api': - return WechatService::receive()->reply($msgData, true); - case 'thr': + case 'api': // 参数对接,直接回复XML来实现消息回复 + $wechat = WechatService::receive(); + switch (strtolower($type)) { + case 'text': + return $wechat->text($data)->reply([], true); + case 'image': + return $wechat->image($data['media_id'])->reply([], true); + case 'video': + return $wechat->video($data['media_id'], $data['title'], $data['description'])->reply([], true); + case 'voice': + return $wechat->voice($data['media_id'])->reply([], true); + case 'music': + return $wechat->music($data['title'], $data['description'], $data['musicurl'], $data['hqmusicurl'], $data['thumb_media_id'])->reply([], true); + case 'news': + return $wechat->news($data['articles'])->reply([], true); + case 'customservice': + WechatService::custom()->send(['touser' => $this->openid, 'msgtype' => 'text', "text" => $data['content']]); + return $wechat->transferCustomerService()->reply([], true); + default: + return 'success'; + } + case 'thr': // 第三方平台,使用客服消息来实现 return WechatService::custom()->send($msgData); default: return 'success';