From 4a9e53831f306637f884e944167a41308e9751ce Mon Sep 17 00:00:00 2001 From: Anyon Date: Wed, 2 May 2018 16:39:28 +0800 Subject: [PATCH] =?UTF-8?q?[=E6=9B=B4=E6=96=B0]=E4=BF=AE=E6=94=B9=E4=BC=98?= =?UTF-8?q?=E5=8C=96=E5=85=AC=E4=BC=97=E5=8F=B7=E6=B6=88=E6=81=AF=E6=8E=A5?= =?UTF-8?q?=E6=94=B6=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/wechat/controller/api/Push.php | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/application/wechat/controller/api/Push.php b/application/wechat/controller/api/Push.php index 320e30e06..2a7fbae84 100644 --- a/application/wechat/controller/api/Push.php +++ b/application/wechat/controller/api/Push.php @@ -49,7 +49,7 @@ class Push protected $receive; /** - * 微信消息接口(通过ThinkService推送) + * 微信消息接口(来自ThinkService授权的消息推送) * @return string * @throws \think\Exception * @throws \think\exception\PDOException @@ -63,11 +63,11 @@ class Push if (empty($this->appid) || empty($this->openid) || empty($this->receive)) { throw new Exception('微信API实例缺失必要参数[appid,openid,receive].'); } - return $this->call($this->appid, $this->openid, $this->receive); + return $this->init(); } /** - * 公众号直接对接(通过参数对接推送) + * 微信消息接口(来自在公众号官方的消息推送) * @return string * @throws \think\Exception * @throws \think\exception\PDOException @@ -75,21 +75,20 @@ class Push public function notify() { $wechat = WechatService::receive(); - return $this->call(WechatService::getAppid(), $wechat->getOpenid(), $wechat->getReceive()); + $this->openid = $wechat->getOpenid(); + $this->receive = $wechat->getReceive(); + $this->appid = WechatService::getAppid(); + return $this->init(); } /** * 初始化接口 - * @param string $appid 公众号APPID - * @param string $openid 公众号OPENID - * @param array $revice 消息对象 * @return string - * @throws \think\Exception + * @throws Exception * @throws \think\exception\PDOException */ - private function call($appid, $openid, $revice) + private function init() { - list($this->appid, $this->openid, $this->receive) = [$appid, $openid, $revice]; if ($this->appid !== WechatService::getAppid()) { throw new Exception('微信API实例APPID验证失败.'); }