欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

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

程序员文章站 2022-03-30 20:56:52
...
返回用户发送的文本消息,修改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);}?>