This commit is contained in:
aozhiwei 2019-01-25 17:12:16 +08:00
parent 33115ca733
commit d018c15443

View File

@ -443,7 +443,7 @@ class KefuController {
#error_log('dot save to db');
$kefu_info = array(
'accountid' => $accountid,
'channel' => 6001,
'channel' => WEIXIN_CHANNEL,
'gameid' => phpcommon\extractGameId($accountid),
'openid' => $openid,
'awardtime' => '0'
@ -463,32 +463,25 @@ class KefuController {
private function responseMsg()
{
$postStr_key = $GLOBALS["HTTP_RAW_POST_DATA"];
$gameid = $_REQUEST['gameid'];
$msg_sign = $_REQUEST['msg_signature'];
$timeStamp = $_REQUEST['timestamp'];
$nonce = $_REQUEST['nonce'];
$msg_str = '';
$pc = new WXBizMsgCrypt(WEIXIN_TOKEN, WEIXIN_MSG_KEY, WEIXIN_APP_ID);
$errcode = $pc->decryptJsonMsg($msg_sign, $timeStamp, $nonce, $postStr_key, $postStr);
$errcode = $pc->decryptJsonMsg($_REQUEST['msg_signature'],
$_REQUEST['timestamp'],
$_REQUEST['nonce'],
file_get_contents('php://input'),
$msg);
if ($errcode == 0) {
#error_log("解密后: " . $postStr . "\n");
if (!empty( $postStr ) && is_string( $postStr )){
$postArr = json_decode( $postStr , true );
$accountid = phpcommon\createAccountId(6001, $gameid, $postArr['FromUserName']);
$msg = json_decode($msg_str, true);
$accountid = phpcommon\createAccountId(WEIXIN_CHANNEL, $_REQUEST['gameid'], $msg['FromUserName']);
if (!empty( $postArr ['MsgType']) && $postArr['MsgType'] == 'text'){ // 文本消息
$this->disposeText($postArr, $accountid);
} elseif (!empty( $postArr ['MsgType']) && $postArr['MsgType'] == 'image'){ // 图文消息
$this->disposeImage($postArr, $accountid);
} elseif (!empty( $postArr ['MsgType']) && $postArr['MsgType'] == 'event' ){ // 进入客服动作
$this->disposeEvent($postArr, $accountid);
} else {
exit ();
}
if (!empty( $msg ['MsgType']) && $msg['MsgType'] == 'text'){ // 文本消息
$this->disposeText($msg, $accountid);
} elseif (!empty( $msg ['MsgType']) && $msg['MsgType'] == 'image'){ // 图文消息
$this->disposeImage($msg, $accountid);
} elseif (!empty( $msg ['MsgType']) && $msg['MsgType'] == 'event' ){ // 进入客服动作
$this->disposeEvent($msg, $accountid);
} else {
echo "" ;
exit ;
exit ();
}
} else {
#error_log($errcode . "\n");