diff --git a/CHANGELOG.md b/CHANGELOG.md index 83a9a502066cbedc0e0c41b0d07029ffc251a001..d212e1f3686879265904a5f850ad56a41e91882d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,7 @@ -## v6.0.107 / 2020-09-03 +## v6.0.109 / 2020-09-04 +- 修复公众号获取access_token问题 + +## v6.0.108 / 2020-09-03 - 修复数组 ## v6.0.107 / 2020-08-15 diff --git a/src/common.php b/src/common.php index 4bd262387efb0438e486f266a12a861f548a14c6..b7dcb04960997951570035b54e457ded169ba479 100644 --- a/src/common.php +++ b/src/common.php @@ -25,7 +25,7 @@ use DtApp\ThinkLibrary\service\SystemService; /** * 定义当前版本 */ -const VERSION = '6.0.108'; +const VERSION = '6.0.109'; if (!function_exists('get_ip_info')) { /** diff --git a/src/service/wechat/WebAppService.php b/src/service/wechat/WebAppService.php index a816d36907bc2721fef36e67e7df724d69fdfe7d..049e1d215337556d48151f338c6c5d61b41aa4fd 100644 --- a/src/service/wechat/WebAppService.php +++ b/src/service/wechat/WebAppService.php @@ -646,10 +646,19 @@ class WebAppService extends Service file_put_contents($file, json_encode($accessToken_res, JSON_UNESCAPED_UNICODE)); $accessToken = $accessToken_res; } - $judge = HttpService::instance() - ->url("{$this->api_url}cgi-bin/getcallbackip?access_token={$accessToken['access_token']}") - ->toArray(); - if (!isset($judge['ip_list'])) { + if (isset($accessToken['access_token'])) { + $judge = HttpService::instance() + ->url("{$this->api_url}cgi-bin/getcallbackip?access_token={$accessToken['access_token']}") + ->toArray(); + if (!isset($judge['ip_list'])) { + $accessToken_res = HttpService::instance() + ->url("{$this->api_url}cgi-bin/token?grant_type={$this->grant_type}&appid={$this->app_id}&secret={$this->app_secret}") + ->toArray(); + $accessToken_res['expires_time'] = time() + 6000; + file_put_contents($file, json_encode($accessToken_res, JSON_UNESCAPED_UNICODE)); + $accessToken = $accessToken_res; + } + } else { $accessToken_res = HttpService::instance() ->url("{$this->api_url}cgi-bin/token?grant_type={$this->grant_type}&appid={$this->app_id}&secret={$this->app_secret}") ->toArray(); @@ -658,7 +667,9 @@ class WebAppService extends Service $accessToken = $accessToken_res; } return $accessToken; - } else if ($this->cache == "mysql") { + } + + if ($this->cache == "mysql") { $access_token = []; // 文件名 $file = "{$this->app_id}_access_token"; @@ -687,9 +698,9 @@ class WebAppService extends Service $access_token['access_token'] = $accessToken_res['access_token']; } return $access_token; - } else { - throw new DtaException("驱动方式错误"); } + + throw new DtaException("驱动方式错误"); } /** @@ -773,10 +784,10 @@ class WebAppService extends Service if ($data) { curl_close($ch); return $data; - } else { - $error = curl_errno($ch); - curl_close($ch); - return "curl error, error code " . $error; } + + $error = curl_errno($ch); + curl_close($ch); + return "curl error, error code " . $error; } }