From 776fc7b50ca35c0884e1a0bc632ada86c833ff7e Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Wed, 31 Jul 2019 11:28:01 +0800 Subject: [PATCH] 1 --- webapp/controller/KefuController.class.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/webapp/controller/KefuController.class.php b/webapp/controller/KefuController.class.php index 07e4a95..140fb40 100644 --- a/webapp/controller/KefuController.class.php +++ b/webapp/controller/KefuController.class.php @@ -224,6 +224,23 @@ class KefuController { } $ret_info = json_decode($response, true); error_log(json_encode($response)); + if (isset($ret_info['errcode']) && $ret_info['errcode'] == 40001) { + error_log('重新获取access_token'); + $r = $this->getRedis($gameid); + $r->del('kf_token:' . $gameid . ':'); + $access_token = $this->getAccessToken($gameid); + $url = "https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token=$access_token"; + + $response = ''; + if (!phpcommon\HttpClient::post($url, + json_encode($data, JSON_UNESCAPED_UNICODE), + $response) + ) { + phpcommon\sendError(ERR_RETRY, '系统繁忙'); + return; + } + $ret_info = json_decode($response, true); + } return !empty($ret_info) && $ret_info['errcode'] == 0; } @@ -393,6 +410,7 @@ class KefuController { $url = "https://api.weixin.qq.com/cgi-bin/media/upload?access_token=$access_token&type=$type"; $response = ''; if (phpcommon\HttpClient::upload($url, $filedata, $response)) { + error_log('getMediaId ' . $response); $jsonobj = json_decode($response, true); if(isset($jsonobj['media_id'])) { return $jsonobj['media_id'];