|MySQL Conference and Expo April 14-17, 2008, Santa Clara, CA|
O'Reilly Book Excerpts: Amazon Hacks
Hacking Amazon, Part 2
Author's note: Amazon has a history of embracing the nature of the Web by opening its platform to outsiders. Its founders realized early that any web site can link to any other web site, and that means hefty competition for attention and links. Amazon turned this apparent chaos to its advantage by creating its Associates Program. The program pays web site owners a percentage of the sales made from referred customers. With a proliferation of competition from sites selling used books, Amazon opened its sales infrastructure to allow anyone to sell the same items it was selling--alongside Amazon's listings. Even Amazon competitors can sell their books on Amazon.com.
With this history in mind, it's not surprising that Amazon has packaged all of these features into a developer-friendly environment that allows web site authors to integrate even more closely with Amazon to take advantage of these features. With an open API based on standard Web services (and a bit of hacking for those features that aren't included in the API yet), developers can integrate Amazon features with their businesses (see Hack #54); cell phones (see Hack #90); desktop applications (see Hack #11); and web sites (see Hack #69). Amazon Hacks gives you 100 concrete examples just like these, showing exactly what features are available, how to use them, and how to make this kind of integration happen.
Hack #54: List Your Items for Sale on Your Web Site
If you have your own web site, you can mirror your Amazon listings there so you can reach your audience as well.
Amazon has millions of customers at their site looking for items, and getting your listing in front of them is important. If you have a web site, though, letting your own audience know about your sale items could be just as important. It's not only the number of people that see a listing that matters, but getting the right person to see the listing.
The easiest way to point your web visitors to your sale items is to link to a list of all your open Marketplace items on Amazon. To find the link, visit your seller account (http://www.amazon.com/seller-account/) and click "View your Member Profile."
TIP: The URL of your Member Profile page contains your Seller ID. The alphanumeric string following
On your member profile page, click "View Open Marketplace Listings." The page lists all of your open sale items. This page is publicly viewable, so just copy the URL from the address bar of your browser and include it in an HTML link on your site like this:
If you want to integrate beyond a link, you can list every item you're selling on your site.
Included in every listing confirmation email [Hack #49] you'll find a link that leads to a page for your specific product listing. If you want to include all of the items you have for sale on your web site, you could copy each of these links and paste them into an HTML file. You'd also need to copy the name of the product and how much you've listed it for. You'd have to revisit this HTML every time an item sells or anytime you make a change to your listings.
Luckily, you can automate this entire process with Amazon Web Services.
This ASP script requests your latest items for sale on Amazon and formats them as a local web page. You'll need an Amazon developer's token Section 6.4 to run the script, and you can include an affiliate tag. You'll also need to find your Seller ID and set it at the top of the code.
Running the Hack
Save the code to a file called SalesListings.asp and upload it to your IIS server. Request the file from a browser to see your product listings:
Hacking the Hack
Taking this script one step further, you can let your visitors add your items directly to their Amazon shopping carts. Include the following HTML form to print a "Buy from Amazon.com" button along with each item.
You'll need to insert the proper exchange ID, ASIN, and Seller ID, and these
values are available as variables in the script. To add this form to SalesListings.asp, insert the following code just before the last line of the loop (
When someone visiting the page clicks "Buy from Amazon.com," your specific item will be added to their cart and the sale will go to you.
Add a Co-Branded Checkout
For more hacking-the-hack fun, you can ease the transition from your site to Amazon's with some co-branding. By setting the following form with each item listing, the "Buy from Amazon.com" button will tell Amazon to show your logo as customers step through the checkout process on their server.
To include this co-branded checkout in SalesListings.asp, just fill in the image, store name, store
URL, and exchange ID, and include the HTML just before the last line of the
product loop. Be sure to turn off script processing with
Instead of sending customers from your site directly to Amazon's cart page, you can send them to a minimalist checkout process (as shown in Figure 4-8) that includes your site's logo.