From 236efcf9d2b6f00739f420e76d80cf3125083783 Mon Sep 17 00:00:00 2001 From: Anyon Date: Thu, 1 Feb 2018 17:15:50 +0800 Subject: [PATCH] =?UTF-8?q?[=E6=9B=B4=E6=96=B0]=E4=BF=AE=E6=94=B9=E7=AC=AC?= =?UTF-8?q?=E4=B8=89=E6=96=B9=E5=B9=B3=E5=8F=B0=E6=9C=8D=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WeChat/Open.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/WeChat/Open.php b/WeChat/Open.php index d6eedb6..6c5b7ca 100644 --- a/WeChat/Open.php +++ b/WeChat/Open.php @@ -22,7 +22,7 @@ use WeChat\Exceptions\InvalidResponseException; /** * 第三方平台支持 - * Class Qrcode + * Class Open * @package WeChat */ class Open extends WeChat @@ -34,6 +34,9 @@ class Open extends WeChat */ public function __construct(array $options) { + if (empty($options['component_token'])) { + throw new InvalidArgumentException("Missing Config -- [component_token]"); + } if (empty($options['component_appid'])) { throw new InvalidArgumentException("Missing Config -- [component_appid]"); } @@ -43,9 +46,6 @@ class Open extends WeChat if (empty($options['component_encodingaeskey'])) { throw new InvalidArgumentException("Missing Config -- [component_encodingaeskey]"); } - if (empty($options['component_token'])) { - throw new InvalidArgumentException("Missing Config -- [component_token]"); - } $this->config = new DataArray($options); } @@ -88,7 +88,7 @@ class Open extends WeChat 'component_verify_ticket' => Tools::get('component_verify_ticket'), ]); if (empty($result['component_access_token'])) { - throw new InvalidResponseException('Get getComponentAccessToken Faild', '0'); + throw new InvalidResponseException('GetComponentAccessToken Faild', '0'); } Tools::setCache($cache, $component_access_token, 7000); } @@ -186,10 +186,10 @@ class Open extends WeChat 'authorization_code' => $_GET['auth_code'], ]); if (empty($result['authorizer_access_token'])) { - throw new InvalidResponseException('GetQueryComponent Faild.', '0'); + throw new InvalidResponseException('GetQueryAuthorizerInfo Faild.', '0'); } $authorizer_appid = $result['authorizer_appid']; - // 缓存授权公众号访问ACCESS_TOKEN + // 缓存授权公众号访问 ACCESS_TOKEN Tools::setCache("{$authorizer_appid}_access_token", $result['authorizer_access_token'], 7000); return $result; } @@ -214,7 +214,7 @@ class Open extends WeChat if (empty($result['authorizer_access_token'])) { throw new InvalidResponseException('RefreshAccessToken Faild', '0'); } - // 缓存授权公众号访问ACCESS_TOKEN + // 缓存授权公众号访问 ACCESS_TOKEN Tools::setCache("{$authorizer_appid}_access_token", $result['authorizer_access_token'], 7000); return $result; }