Before you start
This tutorial is for programmers interested in creating a storefront that automates the process of connecting to Amazon Web Services and displaying the result using PHP. This assumes you are familiar with basic PHP concepts, including
while loops, and form handling. If you are uncertain of your PHP prowess, there are great tutorials available to help you get up to speed (see Resources).
You should be familiar with Amazon Web Services, which are introduced in the developerWorks series "Boost application development with Amazon Web Services" (see Resources).
In this two-part series, we create an Amazon shopping cart with PHP. Part 1 will cover the storefront architecture, displaying selections and browsing categories by communicating to Amazon Web Services through item search requests. We will also create a search box.
Part 2 will cover creating, adding to, and modifying a shopping cart that will be stored entirely on Amazon servers using a technique called cart requests. We will cover building a collectibles shop and giving shoppers the ability to browse for similar items.
We will build an Amazon storefront containing category links and a search box, allowing shoppers to browse categories in your store. Unlike most PHP applications, this one requires no local database, as data is stored on Amazon's servers. Therefore, this tutorial relies heavily on the Simple Object Access Protocol (SOAP), a Web services protocol that organizes information in XML. Web services is the way in which applications, like the PHP application you will build throughout this tutorial, communicate with central servers to obtain information.
Through the Amazon E-Commerce Service (ECS), you will obtain and display content from categories that shoppers choose. When a category is selected, you will create parameters indicating that category, collect other relevant information, and launch a SOAP client. The SOAP client will take the parameters, form an XML document, and relay the XML document to the SOAP server. The Amazon server accesses its databases to create an XML document containing items that match the criteria. Finally, the server returns an XML document to your SOAP client, which parses it into a data structure from which you extract the requested data.
To follow along with this tutorial, you will need to install and test the following tools, and retrieve two identifiers from Amazon:
- Web server
- Pick any Web server and operating system. Feel free to use Apache V2.X, or the IBM HTTP Server.
- You can follow along in this tutorial without PHP, but if you are interested in interacting with the sample application, download PHP V5. Make sure to build PHP with
--enable-soapto enable the PHP SOAP extensions.
- You need two things from Amazon: a developer token and an Amazon Associates ID (see Resources).
- Web Browser
- You need a Web browser. These include Mozilla, Firefox, Opera, and Microsoft® Internet Explorer.