从Ebay API获取送货地址

时间:2015-12-15 10:19:49

标签: php object ebay

我有一个从ebay交易api返回的对象,如bellow,

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

结果

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] => 
        )

)

我需要从这个对象访问Name,Street1等。 我尝试像$address->Name$address[0]->Name$address->Name[0]那样访问它。但是没有获得我想要的数据。

1 个答案:

答案 0 :(得分:0)

我们可以使用toArray()方法,

$address_array = $address->toArray();
print_r($address_array); // address as array