0

I want to get info of an external serve with SOAP. When i do a print_r of that SOAP call i get:

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.
                )

        )

)

This is the PHP code to get the data:

$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"));
      }

How can i display the data of TotalUsage?

galymzhan
  • 5,505
  • 2
  • 29
  • 45
user1079160
  • 811
  • 1
  • 7
  • 11
  • Can you do a `print_r` of `$result` and edit the post with the properly formatted output rather than on one line. Its hard to tell what properties belongs to which ones on a single line. – drew010 Jul 24 '12 at 18:23
  • Changed that.This is how print_r returned it. – user1079160 Jul 24 '12 at 18:25
  • 1
    If you view the page source, it should be properly spaced and contain line breaks. Then indent each line by 4 spaces, or click the code button on SO to format it properly. It's still hard to read. Thanks – drew010 Jul 24 '12 at 18:26
  • Changed that. I didn't know it was formated like that in the source. – user1079160 Jul 24 '12 at 18:32

2 Answers2

3
<?php

$usage = $result->FUP->Usage->TotalUsage;
galymzhan
  • 5,505
  • 2
  • 29
  • 45
2

It's just a PHP object with a number of properties.

You can access TotalUsage like this:

$result->FUP->Usage->TotalUsage;
drew010
  • 68,777
  • 11
  • 134
  • 162