美文网首页
微信-component_verify_ticket解密

微信-component_verify_ticket解密

作者: ShindouHikaru | 来源:发表于2015-05-24 18:21 被阅读2548次
    <?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");
    }
    

    相关文章

      网友评论

          本文标题:微信-component_verify_ticket解密

          本文链接:https://www.haomeiwen.com/subject/eehrqttx.html