此代碼爲我工作,希望你覺得它有用
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;
也許你可以迭代所有的訂單,並檢查它們是否標記爲已發貨:http://stackoverflow.com/questions/14844391/ – McIntosh 2013-03-07 07:50:55
但在這種情況下,我需要指定FromDate ToDate或NumberOfDays。但我並不真正瞭解這些價值。假設我們的易趣帳戶在3天內售出了X件物品。我可以在技術上使用NumberOfDays 3並遍歷每個訂單,但是如果由於某種原因我上週沒有發貨訂單,該怎麼辦?在這種情況下,我將不得不在最後10-15天內處理大量處理時間的數據。 當我訪問eBay上的等待郵資頁面時,它在URL中具有status = WaitShipment屬性。我不相信API沒有這樣的功能.. – Skylight 2013-03-07 11:52:32
如果'GetSellingManagerSoldListings'提供了這些信息,那麼您可以從那裏收集orderIds併爲每個orderId調用'GetOrder'來檢索運送信息。我的另一種方法是每天多次輪詢「GetOrders」,以查看自上次投票後更改的所有訂單,並將收集的運送信息和orderId存儲在本地數據庫中。這樣你就可以向數據庫詢問未發貨的訂單。 – McIntosh 2013-03-07 14:29:31