我想通过SOAP获取外部服务的信息。当我执行SOAP调用的print_r时,我得到:
stdClass Object (
[Ticket] => stdClass Object
(
[Timestamp] => 2012-07-24T17:46:01.306+02:00
[ExpiryTimestamp] => 2012-07-24T18:47:46.626+02:00
)
[FUP] => stdClass Object
(
[Period] => stdClass Object
(
[From] => 2012-06-25+02:00
[Till] => 2012-07-24+02:00
[CurrentDay] => 30
)
[Usage] => stdClass Object
(
[TotalUsage] => 75.1
[MinUsageRemaining] => 182.59
[MaxUsageRemaining] => 612.54
[Unit] => GB
[LastUpdate] => 2012-07-24T17:40:44.000+02:00
)
[Status] => Vrij verbruik
[StatusDescription] => stdClass Object
(
[NL] => Je surft met volledige surfsnelheid.
[FR] => Vous surfez à vitesse normale.
)
)
)
这是获取数据的PHP代码:
$wsdl_url = "https://t4t.services.telenet.be/TelemeterService.wsdl";
$client = new SoapClient($wsdl_url);
try
{
$result = $client->retrieveUsage(new SoapParam(array("UserId" => $userName, "Password" => $password), "RetrieveUsageRequestType"));
}
如何显示TotalUsage的数据?
答案 0 :(得分:3)
<?php
$usage = $result->FUP->Usage->TotalUsage;
答案 1 :(得分:2)
它只是一个具有许多属性的PHP对象。
您可以像这样访问TotalUsage
:
$result->FUP->Usage->TotalUsage;