2015-10-05 67 views
2

我試圖讓我的訂單(項目出售)使用神奇的API davidtsadler /易趣-SDK-PHP獲取易趣SDK出售的商品清單使用davidtsadler /易趣-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頁,雖然我已經「賣」和支付項目即時通訊我的易趣私人Acount

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

) 

回答

1

好 我發現自己的解決方案! 必須pased在所述呼叫的一段時間內關閉GetOrdersRequestType($參數)

「CreateTimeFrom」=>新\日期時間( '2015年1月1日'), 「CreateTimeTo」=>新\日期時間('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); 
+0

得益於良好的人力 – waza123

+0

沒有與此代碼的問題,如果用戶完成了訂單,但尚未支付,它發生在我身上。需要以某種方式檢查,如果支付 – waza123