当前位置:Gxlcms > PHP教程 > 微信企业号开发php版2-文本消息

微信企业号开发php版2-文本消息

时间:2021-07-01 10:21:17 帮助过:25人阅读

返回用户发送的文本消息,修改sample.php

DecryptMsg($sReqMsgSig, $sReqTimeStamp, $sReqNonce, $sReqData, $sMsg);if ($errCode == 0) {	        $postStr=$sMsg;	//以下恢复为普通微信的操作	$postObj = simplexml_load_string($postStr, 'SimpleXMLElement', LIBXML_NOCDATA);    $fromUsername = $postObj->FromUserName;	$toUsername = $postObj->ToUserName;	$content = trim($postObj->Content);    $time = time();    $textTpl = "																					%s																												";      	$sRespData= sprintf($textTpl, $fromUsername, $toUsername, $time, $content);	//加密
输出 $sEncryptMsg = ""; //xml格式的密文$errCode = $wxcpt->EncryptMsg($sRespData, $sReqTimeStamp, $sReqNonce, $sEncryptMsg);if ($errCode == 0) { echo $sEncryptMsg; } else { print("ERR: " . $errCode . "\n\n"); // exit(-1); } } else { print("ERR: " . $errCode . "\n\n"); //exit(-1);}?>

人气教程排行