ddaugherty3
ddaugherty3

Reputation: 101

Amazon.com MWS via PHP

Here is what I want to do:

  1. Access my Amazon Marketplace
  2. Generate and save a report as a CSV file. It must include the following information: ORER-ID, PURCHASE DATE, SKU, PRODUCT NAME, SELL PRICE, and SHIPPING INFORMATION

MWS is a mess. If I'm wrong, please let me know!!

I believe that I have to REQUEST the report first and somehow wait until the report is generated.

Once the Report is generated, I should be able to pull the Report ID and get the information from that. Am I right? Is there a sample available showing this process? Any pitfalls I should watch out for?

I am an intermediate PHP Programmer with limited API/Object Oriented programming knowledge. I have been able to successfully program a site to pull orders ONE-BY-ONE but this throttles the system and locks me out of for a time. I need to send ONE REQUEST for the report instead of several requests for individual orders.

Upvotes: 1

Views: 1721

Answers (2)

mflaming
mflaming

Reputation: 1157

The Temboo SDK RetrieveReport function lets you perform all the steps involved in downloading a single report (request, poll for status, retrieve completed report data) in a single call. The SDK is available for a number of languages, including Java, PHP, Python, Ruby, Node.js, etc., and is an open download. Take a look at:

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

(Full disclosure: I work for Temboo)

Upvotes: 0

Robert H
Robert H

Reputation: 11730

I don't know about PHP as I use C#, but hopefully these steps will help:

    /*  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. 
        *
        */

It took me a while of trial and error to get this working, The API's are OK once you understand what each class is and more specifically where it needs to be instantiated.

The report type I think you are looking for is: _GET_AMAZON_FULFILLED_SHIPMENTS_DATA_ as it contains the majority of info.

I hope these steps help though - it would have saved me a week of debugging had I known them ahead of time :)

Upvotes: 1

Related Questions