-1

I have an object returned from ebay trading api like bellow,

 $address = $order_data->ShippingAddress;
 print_r($address);

Result

DTS\eBaySDK\Trading\Types\AddressType Object
(
    [values:DTS\eBaySDK\Types\BaseType:private] => Array
        (
            [Name] => Test User
            [Street1] => address
            [Street2] => 
            [CityName] => city
            [StateOrProvince] => BUCKINGHAMSHIRE
            [Country] => GB
            [CountryName] => United Kingdom
            [Phone] => 1 800 111 1111
            [PostalCode] => HP19 3EQ
            [AddressID] => 7725220
            [AddressOwner] => eBay
            [ExternalAddressID] => 
        )

    [attachment:DTS\eBaySDK\Types\BaseType:private] => Array
        (
            [data] => 
            [mimeType] => 
        )

)

I need to access Name,Street1 etc from this object. I try to access it like $address->Name , $address[0]->Name ,$address->Name[0] .but not getting the data i wanted.

Shijin TR
  • 7,516
  • 10
  • 55
  • 122
  • Based on the information shown by print_r($address) then echo $address->Name should display the value "Test User". At the moment I can't see any reason as to why it wouldn't. You may need to explain what you mean when you say "but not getting the data i wanted" . Do you mean nothing is been returned or is the wrong information present? –  Dec 15 '15 at 14:14

1 Answers1

0

We can use toArray() method like,

$address_array = $address->toArray();
print_r($address_array); // address as array
Shijin TR
  • 7,516
  • 10
  • 55
  • 122