2013-10-02 135 views
-1

我應該怎麼做才能防止自定義度假的回調函數中的無效XML標記?XML無效標記

$h = fopen("banks/Mybank/log.txt", 'a'); 
     fwrite($h, 'ConfirmRequest: '.print_r($_REQUEST['ConfirmRequest'],true)."\n"); 
     fclose($h); 

輸出爲:

ConfirmRequest: <ConfirmRequest><TransactionId> Cool Attitude #89</TransactionId><PaymentId>327600020200</PaymentId><PaymentDate>02.10.2013 23:41:26</PaymentDate><Amount>7000</Amount><CardType>VISA!472291******9871</CardType><Status>N</Status><Reason>Declined by merchant</Reason></ConfirmRequest> 

結果是相同的上

$_REQUEST['ConfirmRequest']; 

$this->resuest->request['ConfirmRequest']; 

============ ==============

非常感謝gloomy.penguin!你能告訴我,我在這裏做錯了什麼?

if(
     !openssl_verify(
         'ConfirmRequest='.$ConfirmRequest, 
         base64_decode($signature), 
         openssl_get_publickey($cert) 
         ) 
      ) 
      die("signature error"); 




    $parser = xml_parser_create(''); 
     xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, "UTF-8"); 
     xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0); 
      xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1); 
     xml_parse_into_struct($parser, $ConfirmRequest, $vals); 
     xml_parser_free($parser); 


      foreach ($vals as $data) 
        { 
        if ($data['tag']=='STATUS') 
        $Status=$data['value']; 
        if ($data['tag']=='PAYMENTID') 
        $PaymentId=$data['value']; 
        if ($data['tag']=='PAYMENTDATE') 
        $PaymentDate=$data['value']; 
        if ($data['tag']=='TRANSACTIONID') 
        $TransactionId=$data['value']; 
        if ($data['tag']=='AMOUNT') 
        $Amount=$data['value']; 
        if ($data['tag']=='REASON') 
        $Reason=$data['value']; 
       if ($data['tag']=='CARDTYPE') 
        $CardType=$data['value']; 

        } 


      $sta = fopen("banks/MyBank/status.txt", 'a'); 
      fwrite($sta, .print_r($data)."\n"); 
      fclose($sta); 

輸出值爲「1」 ......

+1

['html_entity_decode()'](http://php.net/manual/en/function.html-entity-decode.php) –

+0

謝謝gloomy.penguin !!你能幫我嗎?我已經編輯了我的帖子 – vkatsitadze

+0

你應該在'foreach'之前放置'$ sta = fopen(...'並且把'fwrite(...)放在'foreach'中並離開'fclose',輸出是 –

回答

0

這是回答你最初的問題:html_entity_decode()

既然你是不相關的初始發行一個新的問題,我建議關閉這個問題(通過選擇你的問題的答案),並用你的新問題做一個全新的職位。包括你使用的代碼和變量中的內容,以便人們可以幫助你。

+0

感謝您的關注。你能看到代碼嗎? http://pastebin.com/MCEN8pA5 – vkatsitadze