gpt4 book ai didi

php - 使用 davidtsadler/ebay-sdk-php 在 Ebay SDK 中获取已售商品列表

转载 作者:行者123 更新时间:2023-12-05 05:24:53 27 4
gpt4 key购买 nike

我正在尝试使用 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);
}

尽管我的 Ebay 私有(private)帐户中有“已售出”和已付款的商品,但它返回 0 页。

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

)

最佳答案

嗯我找到了解决方案!在调用 GetOrdersRequestType($args) 时必须经过一段时间

"CreateTimeFrom"=> new\DateTime('2015-01-01'),"CreateTimeTo"=> new\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);

关于php - 使用 davidtsadler/ebay-sdk-php 在 Ebay SDK 中获取已售商品列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32952333/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com