-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」 ......
['html_entity_decode()'](http://php.net/manual/en/function.html-entity-decode.php) –
謝謝gloomy.penguin !!你能幫我嗎?我已經編輯了我的帖子 – vkatsitadze
你應該在'foreach'之前放置'$ sta = fopen(...'並且把'fwrite(...)放在'foreach'中並離開'fclose',輸出是 –