2

我正在尝试使用 api davidtsadler/ebay-sdk-php 获取我的订单(已售商品)列表

https://github.com/davidtsadler/ebay-sdk-php

但我无法获得清单。

我找到了一些例子,但这些对我不起作用。

$service = new Services\TradingService(array(
  'apiVersion' => $this->config['tradingApiVersion'],
  'siteId' => Constants\SiteIds::ES,
  'sandbox'=> true,
));
/**
 * Create the request object.
 *
 * For more information about creating a request object, see:
 * http://devbay.net/sdk/guides/getting-started/#request-object
 */
$request = new Types\GetMyeBaySellingRequestType();
/**
 * An user token is required when using the Trading service.
 *
 * For more information about getting your user tokens, see:
 * http://devbay.net/sdk/guides/application-keys/
 */

$args = array(
  "OrderStatus"   => "Completed",
  "OrderStatus"   => "All",
  "SortingOrder"  => "Ascending",
  //"OrderRole"     => "Seller",
  "ModTimeFrom"   => new \DateTime('2015-01-01'),
);

$getOrders = new Types\GetOrdersRequestType($args);
$getOrders->RequesterCredentials = new Types\CustomSecurityHeaderType();
$getOrders->RequesterCredentials->eBayAuthToken = $this->config['sandbox']['userToken'];
$getOrders->IncludeFinalValueFee = true;
$getOrders->Pagination = new Types\PaginationType();
$getOrders->Pagination->EntriesPerPage = 200;
//$getOrders->OrderIDArray = new Types\OrderIDArrayType();
$getOrdersPageNum = 10;

//$getOrders->OrderIDArray->OrderID[] = '110169861526-110169862570'; //'200980916385-1185594371010'
$response = $service->getOrders($getOrders);

echo print_r($response,1);

foreach ($response->OrderArray->Order as $order) {
  printf("SaleRecordID %s\n", $order->ShippingDetails->SellingManagerSalesRecordNumber);
}

它返回 0 页,尽管我在我的 Ebay 私人帐户中“出售”并支付了物品。

DTS\eBaySDK\Trading\Types\GetOrdersResponseType Object
(
    [values:DTS\eBaySDK\Types\BaseType:private] => Array
        (
            [Timestamp] => DateTime Object
                (
                    [date] => 2015-10-05 15:14:01.578000
                    [timezone_type] => 2
                    [timezone] => Z
                )

            [Ack] => Success
            [Version] => 927
            [Build] => E927_INTL_API_17590342_R1
            [PaginationResult] => DTS\eBaySDK\Trading\Types\PaginationResultType Object
                (
                    [values:DTS\eBaySDK\Types\BaseType:private] => Array
                        (
                            [TotalNumberOfPages] => 0
                            [TotalNumberOfEntries] => 0
                        )

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

                )

            [HasMoreOrders] => 
            [OrderArray] => DTS\eBaySDK\Trading\Types\OrderArrayType Object
                (
                    [values:DTS\eBaySDK\Types\BaseType:private] => Array
                        (
                        )

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

                )

            [OrdersPerPage] => 100
            [PageNumber] => 1
            [ReturnedOrderCountActual] => 0
        )

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

)
4

1 回答 1

1

好吧,我找到了自己的解决方案!它必须在调用GetOrdersRequestType($args) 时传递一段时间

"CreateTimeFrom" => 新的 \DateTime('2015-01-01'), "CreateTimeTo" => 新的 \DateTime('2015-10-06'),

如果不是,则不会检索任何内容。

工作示例:

$service = new Services\TradingService(array(
  'apiVersion' => $this->config['tradingApiVersion'],
  'siteId' => Constants\SiteIds::ES,
  'sandbox'=> true,
));
/**
 * Create the request object.
 *
 * For more information about creating a request object, see:
 * http://devbay.net/sdk/guides/getting-started/#request-object
 */
$request = new Types\GetMyeBaySellingRequestType();
/**
 * An user token is required when using the Trading service.
 *
 * For more information about getting your user tokens, see:
 * http://devbay.net/sdk/guides/application-keys/
 */

$args = array(
  "OrderStatus"   => "Completed",
  "OrderStatus"   => "All",
  "SortingOrder"  => "Ascending",
  //"OrderRole"     => "Seller",
  "CreateTimeFrom"   => new \DateTime('2015-01-01'),
  "CreateTimeTo"   => new \DateTime('2015-10-06'),
);

$getOrders = new Types\GetOrdersRequestType($args);
$getOrders->RequesterCredentials = new Types\CustomSecurityHeaderType();
$getOrders->RequesterCredentials->eBayAuthToken = $this->config['sandbox']['userToken'];
$getOrders->IncludeFinalValueFee = true;
$getOrders->Pagination = new Types\PaginationType();
$getOrders->Pagination->EntriesPerPage = 3;
//$getOrders->OrderIDArray = new Types\OrderIDArrayType();
$getOrdersPageNum = 1;


//$getOrders->OrderIDArray->OrderID[] = '200980916385-1185594371010'; //'200980916385-1185594371010'
$response = $service->getOrders($getOrders);
echo print_r($response,1);

foreach ($response->OrderArray->Order as $order) {
  printf("SaleRecordID %s\n", $order->ShippingDetails->SellingManagerSalesRecordNumber);
}
exit(0);
于 2015-10-05T16:15:29.367 回答