dongze5043 2017-05-19 16:48
浏览 621

亚马逊MWS / PHP /获得所有订单

i'm trying to get ALL orders from amazon mws. i'm aware that i can only get 100 times at a time and need to use the "nextToken2" for paging through the data. however, what i'm not getting is how to set setCreatedAfter and setCreatedBefore for the request .. i find it very confusing that MWS expects both values to be set.

i found this code snippet:

$t1 = date("c", time()-2*24*60*60);
$t2 = date("c", time()-1*24*60*60);
$request = new MarketplaceWebServiceOrders_Model_ListOrdersRequest();
$request->setSellerId(MERCHANT_ID);
$request->setMarketplaceId(marketplace_id);
$request->setCreatedAfter($t1);
$request->setCreatedBefore($t2);

it will get all orders within the past 30 days. but how can i get ALL orders?

  • 写回答

1条回答 默认 最新

  • dongwu9972 2017-05-19 19:10
    关注

    To get all orders via ListOrders, set your setCreatedAfter date to a date before the earliest order that was ever taken. Set the setCreatedBefore date to the current date/time. This is just simply a range of dates for which you want orders returned. You need to create a range big enough to cover all orders.

    After your first call, check for a NextToken. If it exists, you have more orders, so start a loop until NextToken is empty. Once it's empty, you have all orders.

    Be aware of throttling issues. You may have to slow your operation down.

    Another way is to use the Reports API, which avoids throttling issues, but has extra steps to set up.

    评论

报告相同问题?

悬赏问题

  • ¥15 微带串馈天线阵列每个阵元宽度计算
  • ¥15 keil的map文件中Image component sizes各项意思
  • ¥30 BC260Y用MQTT向阿里云发布主题消息一直错误
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 Centos / PETGEM
  • ¥15 划分vlan后不通了
  • ¥20 用雷电模拟器安装百达屋apk一直闪退