企业微信开发url回调成功后的对xml解密出明文
生活随笔
收集整理的這篇文章主要介紹了
企业微信开发url回调成功后的对xml解密出明文
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
include_once "callback/WXBizMsgCrypt.php";(文件自行去企業(yè)微信文檔里下載(https://work.weixin.qq.com/api/doc/90000/90138/90307))
$inputXmlData = file_get_contents('php://input');
$p_params = $request->all();
$corpId = ""; //微信應(yīng)用id
$token = $resMsgtoken['token']; // url驗證token
$encodingAesKey = $resMsgtoken['encoding_aes_key']; // url驗證key
$wxcpt = new WXBizMsgCrypt($token, $encodingAesKey, $corpId);
$sReqMsgSig = $p_params['msg_signature'];
$sReqTimeStamp = $p_params['timestamp'];
$sReqNonce = $p_params['nonce'];
$sReqData = $inputXmlData;
$sMsg = ""; // 解析之后的明文
$errCode = $wxcpt->DecryptMsg($sReqMsgSig, $sReqTimeStamp, $sReqNonce, $sReqData, $sMsg);
if ($errCode == 0) {
//將獲取到的xml數(shù)據(jù)全部轉(zhuǎn)化為Array格式
$decodeMsg = json_decode(json_encode(simplexml_load_string($sMsg, 'SimpleXMLElement', LIBXML_NOCDATA)), true);
if (empty($decodeMsg)) {
Log::info('info', ['sMsg即為xml格式的明文' => $decodeMsg]);
die();
}
}
總結(jié)
以上是生活随笔為你收集整理的企业微信开发url回调成功后的对xml解密出明文的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: tornado 学习笔记17 HTTP
- 下一篇: mongoDb地理空间索引和查询