【问题标题】:Amazon.com MWS via PHPAmazon.com MWS 通过 PHP
【发布时间】:2011-09-14 19:18:40
【问题描述】:

这是我想做的:

  1. 访问我的亚马逊商城
  2. 生成报告并将其保存为 CSV 文件。它必须包含以下信息:ORER-ID、购买日期、SKU、产品名称、售价和运输信息

MWS 一团糟。如果我错了,请告诉我!!

我认为我必须先请求报告,然后以某种方式等待报告生成。

生成报告后,我应该能够提取报告 ID 并从中获取信息。我对吗?是否有可用的示例显示此过程?我应该注意哪些陷阱?

我是一名中级 PHP 程序员,对 API/面向对象的编程知识有限。我已经能够成功地对一个站点进行编程以一个接一个地提取订单,但这会限制系统并将我锁定一段时间。我需要为报告发送一个请求,而不是针对单个订单的多个请求。

【问题讨论】:

  • 祝你好运。我同意 MWS 是一团糟。
  • 您可以使用暂存器获取所需的 http 内容。然后,您可以从那里构建它。 MWS 并没有那么混乱,但它们确实让任何人都很难与之集成。

标签: php amazon-mws


【解决方案1】:

我不了解 PHP,因为我使用 C#,但希望这些步骤会有所帮助:

    /*  To generate a report follow the following steps:              
        * 
        *  1. Create a RequestReportRequest object and populate the required information (merchantID, start date, end date etc.) 
        *  2. Request the report by creating a RequestReportResponse object and executing the service RequestReport method using the object name you instantiated in step 1 and set
        *     string requestID = reportResponse.RequestReportResult.ReportRequestInfo.GeneratedReportId to hold the generated report ID. 
        *  3. Create a GetReportRequestListRequest object and populating the required information. 
        *  4. Request the status of the reports by creating a GetReportRequestListResponse object and executing the GetReportRequestList method using the object name you 
        *     instantiated in step 3. 
        *  5. Execute scheduled checks for the status every 60 seconds using a while loop and a System.Threading.Thread.Sleep(60000) call. This is often within the main program. 
        *  6. Create a foreach loop by creating a ReportRequestInfo object and looping over the GetReportRequestListResult.ReportRequestInfo objects within the 
        *     GetReportRequestListResponse object you instantiated in step 4. 
        *  7. Depending upon the status of the report complete any additional processing required. This is often within the main program
        *  8. Once the report returns _DONE_ the report is ready for download. this is often within the main program
        *  9. Request the report by creating a GetReportRequest object and set the report ID to match the GeneratedReportId object of the ReportRequestInfo object that was 
        *     instantiated in step 6. 
        * 10. Set the Report object of the GetReportRequest object instantiated in step 9 to System.IO.File.Open("filename", System.IO.FileMode.OpenOrCreate, System.IO.FileAccess.ReadWrite) in 
        *     order to download the report to disk in a streaming fashion. **NOTE** An error of "Uninitilized object reference" will be returned if this is not done! 
        * 11. Request the report by creating a GetReportResponse object and executing the service.GetReport method with the GetReportRequest object instantiated in step 9. 
        * 12. The report has been downloaded and processing can be passed off to other methods. 
        *
        */

我花了一些时间试错才能让它工作,一旦你理解了每个类是什么,更具体地说在哪里它需要被实例化,API 就可以了。

我认为您正在寻找的报告类型是:_GET_AMAZON_FULFILLED_SHIPMENTS_DATA_,因为它包含大部分信息。

我希望这些步骤有所帮助 - 如果我提前知道它们,它会为我节省一周的调试时间 :)

【讨论】:

    【解决方案2】:

    Temboo SDK RetrieveReport 功能可让您在一次调用中执行下载单个报告所涉及的所有步骤(请求、轮询状态、检索已完成的报告数据)。该 SDK 可用于多种语言,包括 Java、PHP、Python、Ruby、Node.js 等,并且是开放下载的。看看:

    https://www.temboo.com/library/Library/Amazon/Marketplace/Reports/RetrieveReport/

    (完全披露:我为 Temboo 工作)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-03-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多