<?php
include_once "WXBizMsgCrypt.php";
$encodingAesKey = "XXXX";//接收消息服务器配置的encodingAesKey
$token = "XXX";//接收消息服务器配置的token
$corpId = "XXXX";//公司ID
$sReqMsgSig = $_GET['msg_signature'];
$sReqTimeStamp = $_GET['timestamp'];
$sReqNonce = $_GET['nonce'];
$sReqData = file_get_contents('php://input');//获取post过来的xml
$sMsg = ""; // 解析之后的明文
$wxcpt = new WXBizMsgCrypt($token, $encodingAesKey, $corpId);//
$errCode = $wxcpt->DecryptMsg($sReqMsgSig, $sReqTimeStamp, $sReqNonce, $sReqData, $sMsg);
if ($errCode == 0) {
// 解密成功,sMsg即为xml格式的明文
var_dump($sMsg);
} else {
print("ERR: " . $errCode . "\n\n");
//exit(-1);
}
?>