diff --git a/app/common/service/WechatSubscriptService.php b/app/common/service/WechatSubscriptService.php index 1a17f20..63f0ea4 100644 --- a/app/common/service/WechatSubscriptService.php +++ b/app/common/service/WechatSubscriptService.php @@ -31,6 +31,9 @@ class WechatSubscriptService { try { $access_token = WechatUtil::getAccessToken(); + if(isset($access_token['code'])){ + throw new Exception('获取access_token失败'); + } $result = $this->client->request('post', 'cgi-bin/message/template/send?access_token=' . $access_token, [ 'json' => $send_data, ]); diff --git a/app/utils/WechatUtil.php b/app/utils/WechatUtil.php index d49f3a4..455247b 100644 --- a/app/utils/WechatUtil.php +++ b/app/utils/WechatUtil.php @@ -23,6 +23,7 @@ class WechatUtil try { // $str = '83_0jVm82U7ri-UENTGoTTFh2jowRpAN379ahJvK_3HpLPbdIheIr-ahgYhc5kkHv6dDYyaHklwqffKRQYOxURrQ-H8xq8kYvjoajYZQBNFhMCaBJs0VOU4PE5_-bYPUXfAAAXCF'; // Cache::set(self::GENERAL_ACCESS_TOKEN, $str, 3500); + Cache::delete(self::GENERAL_ACCESS_TOKEN); if (Cache::has(self::GENERAL_ACCESS_TOKEN)) { return Cache::get(self::GENERAL_ACCESS_TOKEN); } else {