时间:2021-07-01 10:21:17 帮助过:18人阅读
返回用户发送的文本消息,修改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 = "输出 $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);}?>"; $sRespData= sprintf($textTpl, $fromUsername, $toUsername, $time, $content); //加密 %s