當我談到SOAP時,我很無知。從結果的其餘肥皂結果變量,PHP
Result
stdClass Object
(
[GetLastRealTimeMetalQuoteResult] => stdClass Object
(
[Outcome] => Success
[Identity] => IP
[Delay] => 0.006
[Symbol] => XAUUSDO
[Type] => XAU
[Currency] => USD
[Date] => 8/1/2011
[Time] => 11:18:48 PM
[Rate] => 1618.88500977
[Bid] => 1618.55004883
[BidTime] => 11:18:48 PM
[Ask] => 1619.2199707
[AskTime] => 11:18:48 PM
)
)
如何分開[競價]出來,並將其存儲在:我執行Web服務調用:
<?php
// define the SOAP client using the url for the service
$client = new soapclient('http://www.xignite.com/xMetals.asmx?WSDL', array('trace' => 1));
// create an array of parameters
$param = array(
'Type' => "XAU",
'Currency' => "USD");
// call the service, passing the parameters and the name of the operation
$result = $client->GetLastRealTimeMetalQuote($param);
// assess the results
if (is_soap_fault($result)) {
echo '<h2>Fault</h2><pre>';
print_r($result);
echo '</pre>';
} else {
echo '<h2>Result</h2><pre>';
print_r($result);
echo '</pre>';
}
?>
,當我運行該腳本,我得到一個變量。
或者更好,但我怎麼能拉出陣列?
請注意,它正在返回一個對象,而不是一個ARRAY。我已經注意到,這些都混在一起了。在第一種情況下返回單個對象時會更糟,但第二種情況下會返回多個對象。你需要爲每種情況分開例程。 –