创建 WXBizMsgCrypt 类所需要的信息(调用方法)
$encodingAesKey = "x";
$token = "x";
$appId = "x";
# 浏览器发送的消息
$timeStamp = $param['timestamp'];
$nonce = $param['nonce'];
$msg_sign = $param['msg_signature'];
# 待解密的消息
$from_xml = $accredit;
$from_xml = str_replace('AppId', 'ToUserName', $from_xml);
$pc = new WXBizMsgCrypt($token, $encodingAesKey, $appId);
// 第三方收到公众号平台发送的消息
$arr = [];
$msg = '';
$errCode = $pc->decryptMsg($msg_sign, $timeStamp, $nonce, $from_xml, $msg);
/*if ($errCode == 0) {
print("解密后: " . $msg . "\n");
} else {
print("出错 :".$errCode . "\n");
}*/
return $msg;
以下是微信官网文件,进行改写兼容php7的文件
链接: https://pan.baidu.com/s/1GB7ujoqncbowRvSGPdH2iQ
提取码: hykg