This commit is contained in:
aozhiwei 2019-08-22 10:20:22 +08:00
parent 6ad5abc7cc
commit a8cb9f0f94
2 changed files with 26 additions and 21 deletions

@ -1 +1 @@
Subproject commit 2e7067d848c09897f27e6486c38399b27126ca26
Subproject commit 1e3bb4df855f6d11df75545d10b0c2aacea34a06

View File

@ -210,26 +210,10 @@ class KefuController {
private function sendKefuMsg($accountid, $data)
{
$gameid = phpcommon\extractGameId($accountid);
$access_token = $this->getAccessToken($gameid);
$url = "https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token=" . urlencode($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);
error_log(json_encode($response));
if (isset($ret_info['errcode']) && ($ret_info['errcode'] == 40001 || $ret_info['errcode'] == 40003)) {
error_log('重新获取access_token');
$r = $this->getRedis($gameid);
$r->del('kf_token:' . $gameid . ':');
try {
$gameid = phpcommon\extractGameId($accountid);
$access_token = $this->getAccessToken($gameid);
$url = "https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token=$access_token";
$url = "https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token=" . urlencode($access_token);
$response = '';
if (!phpcommon\HttpClient::post($url,
@ -240,8 +224,29 @@ class KefuController {
return;
}
$ret_info = json_decode($response, true);
error_log(json_encode($response));
if (isset($ret_info['errcode']) && ($ret_info['errcode'] == 40001 || $ret_info['errcode'] == 40003)) {
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;
} catch (Exception $e) {
error_log($e->getMessage());
return false;
}
return !empty($ret_info) && $ret_info['errcode'] == 0;
}
private function sendOneDBInfo($conn, &$media_conf)