微信-component_verify_ticket解密

2015-05-24  本文已影响2548人  ShindouHikaru
<?php

include_once "wxBizMsgCrypt.php";

// 第三方发送消息给公众平台

$encodingAesKey = "345Aed9rPEea4WaAw3y6hxZ8VuOvjKxb0VtNHCmvEJz";
$token = "weixin";
$timeStamp = $_GET['timestamp'];
$nonce = $_GET['nonce'];
$appId = "wx6365bfa5072ef142";
$msg_sign = $_GET['msg_signature'];
$pc = new  WXBizMsgCrypt($token, $encodingAesKey, $appId);
$postData = $GLOBALS["HTTP_RAW_POST_DATA"];
$postStr = simplexml_load_string($postData,"SimpleXMLElement",LIBXML_NOCDATA);
$encrypt = $postStr->Encrypt;
$format = "<xml><ToUserName><![CDATA[toUser]]></ToUserName><Encrypt><![CDATA[%s]]></Encrypt></xml>";
$from_xml = sprintf($format,$encrypt);
$msg = '';
$errCode = $pc->decryptMsg($msg_sign, $timeStamp, $nonce, $from_xml, $msg);



if ($errCode == 0) {
                print("解密后: " . $msg . "\n");
} else {
                print($errCode . "\n");
}
上一篇下一篇

猜你喜欢

热点阅读