對我的生活中,我想不通爲什麼我不能在這個肥皂分組接入任何屬性(甚至找出它們是什麼)的。我無法使用水星迴歸我的任何東西。我已經閱讀了幾個其他類似的問題,但沒有運氣。我相信這只是我無知的產物,但任何幫助都會受到讚賞。故障解析XML用的SimpleXMLElement
$transactionInfo = new MercuryPaymentHandler($paymentID);
$returnValue = $transactionInfo->verifyPayment();
$xml = new SimpleXMLElement($returnValue);
var_dump(get_object_vars($xml));
回報:
array(0) { }
但這:
$transactionInfo = new MercuryPaymentHandler($paymentID);
$returnValue = $transactionInfo->verifyPayment();
$xml = new SimpleXMLElement($returnValue);
echo $xml->asXML();
回報:
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<VerifyPaymentResponse xmlns="http://www.mercurypay.com/">
<VerifyPaymentResult>
<ResponseCode>0</ResponseCode>
<Status>Approved</Status>
<StatusMessage>AP</StatusMessage>
<DisplayMessage>Your transaction has been approved.</DisplayMessage>
<AvsResult/>
<CvvResult>M</CvvResult>
<AuthCode>000027</AuthCode>
<Token>ItIu8ayb9ZyMcBjHUkyHS0krnFVf6esnfs6tULuAo2giERIQACMQAgyc</Token>
<RefNo>0028</RefNo>
<Invoice>48</Invoice>
<AcqRefData>KbMCC2110080622 </AcqRefData>
<CardType>M/C</CardType><MaskedAccount>xxxxxxxx6781</MaskedAccount>
<Amount>7</Amount>
<TaxAmount>0</TaxAmount>
<TransPostTime>2012-06-22T21:10:08.65</TransPostTime>
<CardholderName>Test-User</CardholderName>
<AVSAddress/>
<AVSZip/>
<TranType>Sale</TranType>
<PaymentIDExpired>true</PaymentIDExpired>
<CustomerCode/>
<Memo>Mighty Wash 2.0</Memo>
<AuthAmount>7</AuthAmount>
<VoiceAuthCode/>
<ProcessData>|00|600550672000</ProcessData>
<OperatorID/>
<TerminalName/>
</VerifyPaymentResult>
</VerifyPaymentResponse>
</soap:Body>
</soap:Envelope>
是怎麼回事?
更新
我從來沒有使用PHP的原生類想通了這一點,但它是與CakePHPs XML類的方式容易。