get url回调调用
include_once "WXBizMsgCrypt.php";
// 假设企业号在公众平台上设置的参数如下
$encodingAesKey = "golSzZAozvH6V1kkYgr8pSkrRW0VP20vrfD5HRerly8";
$token = "lott6";
$receiveid = "ww38e25b8bc500d770"; //corpid
$receiveid = "dk374da9e77729ea74"; //suiteid
$wxcpt = new WXBizMsgCrypt($token, $encodingAesKey, $receiveid);
$sVerifyMsgSig = $_GET['msg_signature'];
$sVerifyTimeStamp = $_GET['timestamp'];
$sVerifyNonce = $_GET['nonce'];
$sVerifyEchoStr = $_GET['echostr'];
$sEchoStr = "";
// call verify function
$errCode = $wxcpt->VerifyURL($sVerifyMsgSig, $sVerifyTimeStamp, $sVerifyNonce, $sVerifyEchoStr, $sEchoStr);
if ($errCode == 0) {
echo $sEchoStr . "\n";
} else {
print("ERR: " . $errCode . "\n\n");
}
post授权回调
$sReqData = file_get_contents('php://input');
$sReqMsgSig = $_GET['msg_signature'];
// $sReqTimeStamp = HttpUtils.ParseUrl("timestamp");
$sReqTimeStamp = $_GET['timestamp'];
// $sReqNonce = HttpUtils.ParseUrl("nonce");
$sReqNonce = $_GET['nonce'];
$sMsg = ""; // 解析之后的明文
$errCode = $wxcpt->DecryptMsg($sReqMsgSig, $sReqTimeStamp, $sReqNonce, $sReqData, $sMsg);
if ($errCode == 0) {
// 解密成功,sMsg即为xml格式的明文
echo "success";
} else {
print("ERR: " . $errCode . "\n\n");
//exit(-1);
}