易趣API。过滤“等待邮资” 或“未发货”的订单,包含送货详情

问题描述 投票:2回答:6

花了不少时间挖掘eBay API文档,找不到任何东西。

在卖家帐户上,我需要获取状态为“等待邮资”​​或“未发货”的所有订单的列表。因此,我可以获取所有目前“未发货”的订单的XML报告,其中包含有关客户的详细信息(送货地址,使用的邮资方式等)

GetOrders不提供未发货订单的过滤器。 GetSellingManagerSoldListings具有此类功能,但未提供有关客户送货详细信息的任何详细信息。

有没有人有这样的问题?

提前致谢。

ebay
6个回答
4
投票

GetOrders不为未发货的订单提供过滤器。但是如果您的GetOrders请求中有[ShippedTime]的对象意味着该订单是为未发货的物品发货的,那么您将无法获得[ShippedTime]的对象...你可以查询未发货的订单


1
投票

好吧,我通过使用php下载params来获得订单。

$xmlReq = '<?xml version="1.0" encoding="utf-8"?>';
$xmlReq .= '<GetSellingManagerSoldListingsRequest xmlns="urn:ebay:apis:eBLBaseComponents">';
$xmlReq .= '<UserID>'.$YOUR_EBAY_APP_ID.'</UserID>';
$xmlReq .= '<Filter>PaidNotShipped</Filter>';
$xmlReq .= '<Pagination><EntriesPerPage>200</EntriesPerPage><PageNumber>1</PageNumber></Pagination>';
$xmlReq .= '<ErrorLanguage>en_US</ErrorLanguage>';
$xmlReq .= "<Version>$version</Version>";
$xmlReq .= '<WarningLevel>Low</WarningLevel>';
$xmlReq .= "<RequesterCredentials><eBayAuthToken>$YOUR_AUTH_TOKEN</eBayAuthToken></RequesterCredentials>\n";    
$xmlReq .= '</GetSellingManagerSoldListingsRequest>';

我希望你得到过滤器参数“PaidNoTShipped”。您将在此响应中获得order_line_item_id,并使用此只是使用此订单行项目ID GetOrderTransactions进行另一次调用,您将获得其余信息。在GetOrderTransactions中使用<DetailLevel>ReturnAll</DetailLevel>来获得扩展结果。如果您想了解更多有关api通话的信息​​,请与我们联系。


0
投票

在一段时间内,我一直在寻找这个问题的解决方案。这是一个非常古老的问题,但我希望它有一个更直接的答案。会救我几个小时。 @Moazam有正确的想法,但真的缺乏特异性,所以这里。以下答案是用python编写的,基于/使用eBay's Api。 (你认为这会更容易找到/做)

from ebaysdk.trading import Connection as Trading
from ebaysdk.exception import ConnectionError
import bs4 as bs # beautifulsoup import for parsing xml

try:
    api = Trading(config_file="ebay.yaml") #put ur eBay dev API credentials in yaml file
    response = api.execute('GetSellerTransactions', {}) # dictionary response
    dommy = response.content 

except ConnectionError as e: # spit error if can't connect (ie: wrong api credz)
    print(e)
    print(e.response.dict())

soup = bs.BeautifulSoup(dommy, 'lxml') # parse the API response as xml
tArray = soup.transactionarray 

with open('fullSoldLogXML.xml', 'w+') as xml: # Log file, not required.
    xml.write(str(soup)) # write entire ebay response to log file.

with open('singleTransactions.xml', 'w+') as tranXml: # Another log. Personal reference.
    tranXml.write(str(tArray)) # parse all transactions from transactionarray in xml 

for each in tArray: # tArray is every transaction, in transactionarray)
    print each.shippedtime # print shipped time, if None then hasn't been shipped.

应该输出这样的东西:

<shippedtime>2016-12-18T15:12:22.000Z</shippedtime>
<shippedtime>2016-12-20T00:35:43.000Z</shippedtime>
<shippedtime>2016-12-20T01:50:37.000Z</shippedtime>
None

有了这些信息,您可以在每笔交易中执行try/except循环。 If shippedtime == None,然后你可以剖析订单并获得有用的信息,如print each.shippingaddress, each.orderlineitemid, each.paidtime等...


0
投票

GetOrders有RequiredSellerAction标签,显示卖家必须做的下一个动作。

对于未发货的订单,它是'MarkAsShipped'

<PaymentHoldDetails>
<ExpectedReleaseDate>2018-04-20T07:00:00.000Z</ExpectedReleaseDate>
<RequiredSellerActionArray>
<RequiredSellerAction>MarkAsShipped</RequiredSellerAction>
</RequiredSellerActionArray>
<NumOfReqSellerActions>1</NumOfReqSellerActions>
<PaymentHoldReason>CasualSeller on https://www.aihello.com </PaymentHoldReason>
</PaymentHoldDetails>

0
投票

这是我做'hacky'的方式:

try
{
$ShippedTime = $order->ShippedTime;
if($ShippedTime && isset($ShippedTime))
$ShippedTime = $ShippedTime->format('d-m-Y H:i:s');
else
$ShippedTime = 'awaiting dispatch'; 
}
catch(Exception $e)
{
 $ShippedTime = 'awaiting dispatch'; 
}

-1
投票

这段代码对我有用,希望你发现它很有用

 date_default_timezone_set('Europe/London');
 $page = 0;
 $order_count = 0;
 $shipped_count = 0;
 do
 {
     $page++;


    $feed = <<< EOD
<?xml version="1.0" encoding="utf-8"?>
<GetOrdersRequest xmlns="urn:ebay:apis:eBLBaseComponents">
<RequesterCredentials>
<eBayAuthToken>$auth_token</eBayAuthToken>
</RequesterCredentials>
<OrderRole>Seller</OrderRole>
<OrderStatus>Completed</OrderStatus>
<Pagination>
<EntriesPerPage>100</EntriesPerPage>
<PageNumber>$page</PageNumber>
</Pagination>
<NumberOfDays>7</NumberOfDays>
<ErrorLanguage>en_GB</ErrorLanguage>
<Version>823</Version>
<WarningLevel>High</WarningLevel>
</GetOrdersRequest>?
EOD;

$feed = trim($feed);
     $site_id = 3;//3 For UK
     $call_name = 'GetOrders';
     $headers = array
         (
         'X-EBAY-API-COMPATIBILITY-LEVEL: ' . $compat_level,
         'X-EBAY-API-DEV-NAME: ' . $dev_id,
         'X-EBAY-API-APP-NAME: ' . $app_id,
         'X-EBAY-API-CERT-NAME: ' . $cert_id,
         'X-EBAY-API-CALL-NAME: ' . $call_name,
         'X-EBAY-API-SITEID: ' . $site_id,
     );

     // Send request to eBay and load response in $response
     $connection = curl_init();
     curl_setopt($connection, CURLOPT_URL, $api_endpoint);
     curl_setopt($connection, CURLOPT_SSL_VERIFYPEER, 0);
     curl_setopt($connection, CURLOPT_SSL_VERIFYHOST, 0);
     curl_setopt($connection, CURLOPT_HTTPHEADER, $headers);
     curl_setopt($connection, CURLOPT_POST, 1);
     curl_setopt($connection, CURLOPT_POSTFIELDS, $feed);
     curl_setopt($connection, CURLOPT_RETURNTRANSFER, 1);
     $response = curl_exec($connection);
     curl_close($connection);

     $order_count += substr_count($response, "<Order>");
     $shipped_count += substr_count($response, "<ShippedTime>");
 }
 while(stristr($response, "<HasMoreOrders>true</HasMoreOrders>") != FALSE OR stristr($response, "<HasMoreOrders>true</HasMoreOrders>") != 0);
 $unshipped_orders = $order_count - $shipped_count;
© www.soinside.com 2019 - 2024. All rights reserved.