推送component_verify_ticket


include_once "wxBizMsgCrypt.php";

// 第三方发送消息给公众平台
$encodingAesKey = "";
$token = "";
$timeStamp = $_GET['timestamp']  ;
$nonce = $_GET['nonce']  ;
$appId = "";
$encryptMsg = file_get_contents ( 'php://input' );


$pc = new WXBizMsgCrypt($token, $encodingAesKey, $appId);

$xml_tree = new DOMDocument();
$xml_tree->loadXML($encryptMsg);
$array_e = $xml_tree->getElementsByTagName('Encrypt');
$array_s = $xml_tree->getElementsByTagName('MsgSignature');
$encrypt = $array_e->item(0)->nodeValue;
$msg_sign = $array_s->item(0)->nodeValue;
$msg_sign = "a2ed9139898089365ede396ef797d866aedecbb8";


$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");
}

$xml = new DOMDocument();
$xml->loadXML($msg);
$array_e = $xml->getElementsByTagName('ComponentVerifyTicket');
echo $encrypt = $array_e->item(0)->nodeValue;

展开阅读全文

没有更多推荐了,返回首页