diff --git a/README.md b/README.md index 8940044..d3f7c39 100644 --- a/README.md +++ b/README.md @@ -61,7 +61,7 @@ $config['GetAccessTokenCallback'] = function ($authorizer_appid) use ($config) { $authorizer_refresh_token = ''; // 通过$authorizer_appid从数据库去找吧,在授权绑定的时候获取 $result = $open->refreshAccessToken($authorizer_appid, $authorizer_refresh_token); if (empty($result['authorizer_access_token'])) { - throw new \WeChat\Exceptions\InvalidResponseException($result['errmsg'], '0'); + throw new \WeChat\Exceptions\InvalidResponseException($result['errmsg']??'system error', '0'); } $data = [ 'authorizer_access_token' => $result['authorizer_access_token'], diff --git a/WeOpen/Service.php b/WeOpen/Service.php index 5d8558f..567ea50 100644 --- a/WeOpen/Service.php +++ b/WeOpen/Service.php @@ -99,7 +99,7 @@ public function getComponentAccessToken() $url = 'https://api.weixin.qq.com/cgi-bin/component/api_component_token'; $result = $this->httpPostForJson($url, $data); if (empty($result['component_access_token'])) { - throw new InvalidResponseException($result['errmsg'], $result['errcode'], $data); + throw new InvalidResponseException($result['errmsg']??'system error', $result['errcode']??-1, $data); } Tools::setCache($cache, $result['component_access_token'], 7000); return $result['component_access_token']; @@ -122,7 +122,7 @@ public function getAuthorizerInfo($authorizerAppid) ]; $result = $this->httpPostForJson($url, $data); if (empty($result['authorizer_info'])) { - throw new InvalidResponseException($result['errmsg'], $result['errcode'], $data); + throw new InvalidResponseException($result['errmsg']??'system error', $result['errcode']??-1, $data); } return $result['authorizer_info']; } @@ -244,7 +244,7 @@ public function getQueryAuthorizerInfo($authCode = null) ]; $result = $this->httpPostForJson($url, $data); if (empty($result['authorization_info'])) { - throw new InvalidResponseException($result['errmsg'], $result['errcode'], $data); + throw new InvalidResponseException($result['errmsg']??'system error', $result['errcode']??-1, $data); } $authorizerAppid = $result['authorization_info']['authorizer_appid']; $authorizerAccessToken = $result['authorization_info']['authorizer_access_token']; @@ -272,7 +272,7 @@ public function refreshAccessToken($authorizerAppid, $authorizerRefreshToken) ]; $result = $this->httpPostForJson($url, $data); if (empty($result['authorizer_access_token'])) { - throw new InvalidResponseException($result['errmsg'], $result['errcode'], $data); + throw new InvalidResponseException($result['errmsg']??'system error', $result['errcode']??-1, $data); } // 缓存授权公众号访问 ACCESS_TOKEN Tools::setCache("{$authorizerAppid}_access_token", $result['authorizer_access_token'], 7000); diff --git a/_test/open.php b/_test/open.php index 6699927..84f62f1 100644 --- a/_test/open.php +++ b/_test/open.php @@ -33,7 +33,7 @@ $authorizer_refresh_token = 'L5uFIa0U6KLalPyXckyqoVIJYLhsfrg8k9YzybZIHsx'; // 从数据库去找吧,在授权绑定的时候获取到了 $result = $open->refreshAccessToken($authorizer_appid, $authorizer_refresh_token); if (empty($result['authorizer_access_token'])) { - throw new \WeChat\Exceptions\InvalidResponseException($result['errmsg'], '0'); + throw new \WeChat\Exceptions\InvalidResponseException($result['errmsg']??'system error', '0'); } $data = [ 'authorizer_access_token' => $result['authorizer_access_token'], diff --git a/composer.json b/composer.json index c26223c..fea2cf2 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "type": "library", - "name": "zoujingli/weopen-developer", + "name": "qfz9527/weopen-developer", "homepage": "https://github.com/zoujingli/WeOpenDeveloper", "description": "WeChat Open Platform Development", "license": "MIT",