Amazon.com MWS через PHP

Вот что я хочу сделать:

  1. Доступ к моему рынку Amazon
  2. Создайте и сохраните отчет в виде файла CSV. Он должен включать следующую информацию: ORER-ID, ДАТУ ПОКУПКИ, SKU, НАЗВАНИЕ ПРОДУКТА, ЦЕНУ ПРОДАЖИ и ИНФОРМАЦИЯ О ДОСТАВКЕ.

МВС - это бардак. Если я ошибаюсь, дайте мне знать!!

Я считаю, что я должен сначала ЗАПРОСИТЬ отчет и как-то подождать, пока отчет не будет сгенерирован.

Как только отчет будет сгенерирован, я смогу получить идентификатор отчета и получить информацию из него. Я прав? Есть ли образец, показывающий этот процесс? Есть ли какие-то подводные камни, которых мне следует остерегаться?

Я программист PHP среднего уровня с ограниченными знаниями API/объектно-ориентированного программирования. Мне удалось успешно запрограммировать сайт на выполнение заказов ОДИН ЗА ОДНИМ, но это тормозит систему и блокирует меня на какое-то время. Мне нужно отправить ОДИН ЗАПРОС на отчет вместо нескольких запросов на отдельные заказы.


person ddaugherty3    schedule 14.09.2011    source источник
comment
Удачи. Я согласен, что MWS - это бардак.   -  person maxedison    schedule 14.09.2011
comment
Вы можете просто использовать блокнот, чтобы получить необходимый http-контент. Затем вы можете построить его оттуда. MWS не такой уж и беспорядок, но с ним довольно сложно интегрироваться.   -  person McStuffins    schedule 10.08.2016


Ответы (2)


Я не знаю о 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_, так как он содержит большую часть информации.

Я надеюсь, что эти шаги помогут - это сэкономило бы мне неделю отладки, если бы я знал их заранее :)

person Robert H    schedule 22.03.2012

Функция Temboo SDK RetrieveReport позволяет выполнять все шаги, связанные с загрузкой одного отчета (запрос, опрос статуса, получение данных завершенного отчета) за один вызов. SDK доступен для ряда языков, включая Java, PHP, Python, Ruby, Node.js и т. д., и его можно загрузить в открытом доступе. Взгляни на:

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

(Полное раскрытие: я работаю на Тембу)

person mflaming    schedule 22.03.2013