Amazon MWS (PHP) - How the request works

I am trying to output a report in PHP for active ads.

I have made progress, however, I cannot understand how this works, and there is nothing to explain this.

For example, in the Samples provided from the PHP library, I see quite a lot of XML files. When you run the RequestReportResponse sample, does this XML file generate or does the XML file tell RequestReportResponse what to do based on the values โ€‹โ€‹and functions?

I ask, because with the help of MWS Scratchpad - I select all the required fields, send them, and then refresh the Amazon Reports page of the central part of my seller and show the pending report.

I'm just asking how the XML content affects the report or how the report can affect the XML.

+4
source share
1 answer

The answer to your question consists of two parts.

Part 1 - Calling the Amazon API

Most MWS requests do not require any file (be it plain text or XML) to send to Amazon. For example, all parameters necessary to send send RequestReport can (and should) be sent as normal parameters. I'm not sure what Amazon would do if you sent the file along with it, like I never tried. But then again ... why do you need it?

One of the calls for which you want to send a file is a call to SubmitFeed , where this file is the actual feed that will be sent. It depends on the type of feed you submit if Amazon expects it to be plain text or XML.

Part 2 - Processing Amazon API responses

When you retrieve information back from the Amazon API, it is usually in XML format (there are several calls that may return plain text instead). You will need to decode this data to get the information.

To make this a little clearer, I will describe a typical process for you:

The process of getting all your ads with Amazon:

  • Make a RequestReport call on Amazon. No XML Attached
  • Decrypt the XML you return (this is RequestReportResponse ). If all goes well, you will receive RequestReportId as part of the response, and Amazon will begin processing your request.

    Amazon may take several minutes to actually generate a report, in cases of very complex or large requests, or during busy hours, it may take up to an hour or more. Therefore, we need to find out when the request made by us is really made.

  • Poke Amazon API with a GetReportRequestList call requesting the status of your request with ReportRequestIdList.Id.1={YourRequestIdHere} . This also does not require an XML attachment.

  • Decrypt the XML you are returning. (this is GetReportRequestListResponse )

    If its ReportProcessingStatus not _DONE_ , wait at least 45 seconds, and then repeat from step 3. If the report is really executed, you will see a valid GeneratedReportId in the response. If it is missing, you need to make an additional call to GetReportList to find its identifier.

  • Call GetReport to finally get the report using ReportId={YourGeneratedReportIdHere}

  • Decode everything that you return. Depending on the type of report requested, the response may be XML or plain text.

    This process is explained in detail (and with a beautiful flowchart) in the Amazon Marketplace Web Services Reporting API Reference (version 2009-01-01)

To finally answer your question about getting active ads from Amazon MWS: None of the three calls require you to submit XML to Amazon. The data you receive from Amazon will be in XML format (with a possible exception step 6, if you requested a simple text report).

+13
source

Source: https://habr.com/ru/post/1498092/


All Articles