zoukankan      html  css  js  c++  java
  • FromXml 支付回调 xml 转数组

        public function xx(){
            $xml = '<xml><appid><![CDATA[xxxxxxxxxxxxx]]></appid>
                    <bank_type><![CDATA[CFT]]></bank_type>
                    <cash_fee><![CDATA[3500]]></cash_fee>
                    <fee_type><![CDATA[CNY]]></fee_type>
                    <is_subscribe><![CDATA[N]]></is_subscribe>
                    <mch_id><![CDATA[xxxxxxxxxxxx]]></mch_id>
                    <nonce_str><![CDATA[xxxxxxxxxxxxx]]></nonce_str>
                    <openid><![CDATA[xxxxxxxxxxxxxxxxxxxxxxxxxx]]></openid>
                    <out_trade_no><![CDATA[111400xxxxxxxxxxxxxx]]></out_trade_no>
                    <result_code><![CDATA[SUCCESS]]></result_code>
                    <return_code><![CDATA[SUCCESS]]></return_code>
                    <sign><![CDATA[DBBB36A12ECE7E3Cxxxxxxxxxxxxxxxx]]></sign>
                    <time_end><![CDATA[20191114005240]]></time_end>
                    <total_fee>3500</total_fee>
                    <trade_type><![CDATA[JSAPI]]></trade_type>
                    <transaction_id><![CDATA[42000004xxxxxxxxxxxxxxxxxxxx3]]></transaction_id>
                    </xml>';
    
            $data = $this->FromXml($xml);
            dump($data);
        }
    
    
    
        public function FromXml($xml)
        {
            if(!$xml){
                throw new WxPayException("xml数据异常!");
            }
    
            //将XML转为array
            //禁止引用外部xml实体
            libxml_disable_entity_loader(true);
            $this->values = json_decode(json_encode(simplexml_load_string($xml, 'SimpleXMLElement', LIBXML_NOCDATA)), true);
            return $this->values;
        }


    <pre>array(16) {
    [&quot;appid&quot;] =&gt; string(18) &quot;xxxxxxxxxxxxxxxxxxx&quot;
    [&quot;bank_type&quot;] =&gt; string(3) &quot;CFT&quot;
    [&quot;cash_fee&quot;] =&gt; string(4) &quot;3500&quot;
    [&quot;fee_type&quot;] =&gt; string(3) &quot;CNY&quot;
    [&quot;is_subscribe&quot;] =&gt; string(1) &quot;N&quot;
    [&quot;mch_id&quot;] =&gt; string(10) &quot;xxxxxxxxxxxxx&quot;
    [&quot;nonce_str&quot;] =&gt; string(16) &quot;Oec5xxxxxxxxxxxxx&quot;
    [&quot;openid&quot;] =&gt; string(28) &quot;xxxxxxxxxxxxxxxxxxxxxxxxxxxxx&quot;
    [&quot;out_trade_no&quot;] =&gt; string(18) &quot;111400522494411933&quot;
    [&quot;result_code&quot;] =&gt; string(7) &quot;SUCCESS&quot;
    [&quot;return_code&quot;] =&gt; string(7) &quot;SUCCESS&quot;
    [&quot;sign&quot;] =&gt; string(32) &quot;DBBB36A12ECxxxxxxxxxxxxxxxxxxxxxxxxxx&quot;
    [&quot;time_end&quot;] =&gt; string(14) &quot;20191114005240&quot;
    [&quot;total_fee&quot;] =&gt; string(4) &quot;3500&quot;
    [&quot;trade_type&quot;] =&gt; string(5) &quot;JSAPI&quot;
    [&quot;transaction_id&quot;] =&gt; string(28) &quot;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx&quot;
    }
    </pre>






  • 相关阅读:
    服务列表
    Tinyfool的2013年总结————在困惑和挣扎中试图前行
    支付平台程序,支付程序,网络pos程序,api接口程序,锋锐支付平台程序开发领导者!
    是新浪移动云
    Convert SVG to PNG in Python
    qrcode 4.0.4 : Python Package Index
    CairoSVG
    cairo graphics.org
    The Apache™ Batik Project
    Online SVG to PNG/JPEG/TIFF conversion
  • 原文地址:https://www.cnblogs.com/pansidong/p/11855622.html
Copyright © 2011-2022 走看看