Home > Article > Backend Development > Use of Amazon API
As mentioned above, a Japanese friend wanted to open a store on Amazon and asked me to help him make a small application. The main function he wants to achieve is to regularly obtain the lowest price of a certain product. If the price is not within the range he set, send him an email as a reminder.
In order to help me complete the program, he also found me a Japanese blog that introduced how to use Amazon’s API. Its principle is to splice a URL through a complex set of rules, then access this URL to obtain the XML format data returned by Amazon, and then obtain the desired product price information. When I directly downloaded and read Amazon's official documentation, I found a more labor-saving method. In fact, Amazon has provided users with a convenient website through which they can customize their own query content, directly query or generate codes. This website is called Amazon Scratchpad (the settings shown here are for Japan and Asia. If you need to query Amazon in China, just change the Marketplace to China). The setting part is as follows: The generated code is as follows: Save the code it generates into a method (for example, called generateURL, the last few lines of the code need to be slightly modified , use the last generated URL as the return object of the method instead of echoing it out), and then use this method as shown below.$url = generateURL($asin); $responseXML = file_get_contents($url); $parsedXML = simplexml_load_string($responseXML);
The above introduces the use of Amazon API, including opening a store and sending emails. I hope it will be helpful to friends who are interested in PHP tutorials.