remove responseMsg

This commit is contained in:
aozhiwei 2019-01-27 19:48:35 +08:00
parent 27a50bfdbe
commit be0443b4a2

View File

@ -207,8 +207,43 @@ class KefuController {
} else {
echo 'signature error';
}
die();
return;
}
$msg_str = '';
$pc = new WXBizMsgCrypt(WEIXIN_TOKEN, WEIXIN_MSG_KEY, WEIXIN_APP_ID);
$errcode = $pc->decryptJsonMsg($_REQUEST['msg_signature'],
$_REQUEST['timestamp'],
$_REQUEST['nonce'],
file_get_contents('php://input'),
$msg_str);
if ($errcode == 0) {
$msg = json_decode($msg_str, true);
$accountid = phpcommon\createAccountId(WEIXIN_CHANNEL, $_REQUEST['gameid'], $msg['FromUserName']);
switch ($msg['MsgType']) {
case 'text':
{
// 文本消息
$this->processText($msg, $accountid);
break;
}
case 'image':
{
// 图文消息
$this->processImage($msg, $accountid);
break;
}
case 'event':
{
// 进入客服动作
$this->processEvent($msg, $accountid);
break;
}
}
} else {
$this->responseMsg();
#error_log($errcode . "\n");
}
}
@ -374,16 +409,11 @@ class KefuController {
private function processImage($msg, $accountid)
{
$openid = $msg['FromUserName'];
$CreateTime = $msg['CreateTime'];
die();
die('not implement');
}
private function processEvent($msg, $accountid)
{
$openid = $msg['FromUserName'];
$CreateTime = $msg['CreateTime'];
if ($msg['Event'] == 'user_enter_tempsession') {
$conn = $this->getMysql($accountid);
$ret = $conn->execScript('INSERT INTO accounts_kefu(accountid, channel, gameid, openid, awardtime) ' .
@ -394,53 +424,17 @@ class KefuController {
':accountid' => $accountid,
':channel' => WEIXIN_CHANNEL,
':gameid' => phpcommon\extractGameId($accountid),
':openid' => $openid,
':openid' => $msg['FromUserName'],
':awardtime' => 0
));
if ($ret) {
$this->sendMsg($accountid, array(
"touser" => $openid,
"touser" => $msg['FromUserName'],
"msgtype" => "text",
"text" => array ("content" => "您好,有什么能帮助你? \n回复指定文字领取奖励。 ")
"text" => array("content" => "您好,有什么能帮助你? \n回复指定文字领取奖励。 ")
));
}
}
private function responseMsg()
{
$msg_str = '';
$pc = new WXBizMsgCrypt(WEIXIN_TOKEN, WEIXIN_MSG_KEY, WEIXIN_APP_ID);
$errcode = $pc->decryptJsonMsg($_REQUEST['msg_signature'],
$_REQUEST['timestamp'],
$_REQUEST['nonce'],
file_get_contents('php://input'),
$msg_str);
if ($errcode == 0) {
$msg = json_decode($msg_str, true);
$accountid = phpcommon\createAccountId(WEIXIN_CHANNEL, $_REQUEST['gameid'], $msg['FromUserName']);
switch ($msg['MsgType']) {
case 'text':
{
// 文本消息
$this->processText($msg, $accountid);
break;
}
case 'image':
{
// 图文消息
$this->processImage($msg, $accountid);
break;
}
case 'event':
{
// 进入客服动作
$this->processEvent($msg, $accountid);
break;
}
}
} else {
#error_log($errcode . "\n");
}
}
private function getAccessToken($accountid)