Amazon Hacks Free Open Book

Amazon Hacks

Previous Section Next Section

Hack 30 Add Pop-up Amazon Reviews to Your Web Site

figs/moderate.giffigs/hack30.gif

With a few lines of JavaScript, you can add Amazon customer reviews to your web site.

The Amazon pop-up review service is a simple yet powerful way to integrate your site with Amazon. It allows anyone with a web site to generate dynamic customer reviews without needing to know anything about Amazon's API (see Chapter 6). An independent developer has provided this service to anyone who would like to use it.

All you need to set up the service on your site is a product's ASIN [Hack #1]. When a visitor clicks the pop-up review link, the application receives the ASIN, connects to Amazon's API, downloads the specific XML data, and parses through it to build the product page with reviews. The data is then displayed on a stylized web page in a new browser window.

30.1 The Code

Displaying the generated code in a pop-up window takes just two easy steps. First, create a new HTML page and paste the following JavaScript between the <head></head> tags. This code creates a function called AmazonLookup that will control the state of the pop-up window and initiate a link to the remote server.

<script type="text/javascript">
    function AmazonLookUp(ASIN) {

      // Set pop-up window properties
      var winoptions = 'toolbar=no,';
      winoptions += 'menubar=no,';
      winoptions += 'location=no,';
      winoptions += 'scrollbars=yes,';
      winoptions += 'resizable=yes,';
      winoptions += 'statusbar=yes,';
      winoptions += 'width=470,';
      winoptions += 'height=500';

//Set the remote service URL, including the ASIN
var URL = "http://www.explodingfist.com/quickreview/index.php?ASIN="+ASIN

//Open a new window with the remote URL
OpenWin = this.open(URL, "Amazon", winoptions);
    }
</script>

30.2 Running the Hack

To open the pop-up window and establish a connection with the service, you simply invoke the JavaScript function you created above. For example, to generate customer reviews for The Matrix on DVD you would insert the following link anywhere in the body of the page. (Note the ASIN inside the single quotes; we are passing it to the service as a parameter.)

<a href="javascript:AmazonLookUp('B00000K19E')">The Matrix on DVD</a>

It's that simple! As you can see in Figure 3-2, the link will open a new browser window where you can read customer reviews, see product information, and even add The Matrix to your Amazon shopping cart.

Figure 3-2. Amazon pop-up review
figs/amzh_0302.gif

For further information on this hack, to download the code, or to see a working demo, visit http://www.explodingfist.com/amazonhack/.

—Reid Philpot

    Previous Section Next Section
    Index: [SYMBOL][A][B][C][D][E][F][G][H][I][J][L][M][N][O][P][Q][R][S][T][U][V][W][X][Z]


         Main Menu
    Main Page
    Table of content
    Copyright
    Credits
    Foreword
    Preface
    Chapter 1. Browsing and Searching
    Chapter 2. Controlling Your Information
    Chapter 3. Participating in the Amazon Community
    3.1 Hacks #27-48
    3.2 Community Features
    3.3 Accessing Community Features
    Hack 27 Write a Review
    Hack 28 Link Directly to Reviews of a Product
    Hack 29 Post a Review from a Remote Site
    Hack 30 Add Pop-up Amazon Reviews to Your Web Site
    Hack 31 Send an Email Alert if a Review Is Added to a Product
    Hack 32 Sort Books by Average Customer Rating
    Hack 33 Sort Your Recommendations by Average Customer Rating
    Hack 34 Scrape Product Reviews
    Hack 35 Publish Your Amazon Reviews on Your Site
    Hack 36 Share the Love (and Savings!) with Your Friends
    Hack 37 Create a Guide
    Hack 38 Post a Guide Remotely
    Hack 39 Add Product Advice Remotely
    Hack 40 Scrape Customer Advice
    Hack 41 Create a Listmania! List
    Hack 42 Gather Your Friends on Amazon
    Hack 43 Gather Your Friends' Amazon IDs
    Hack 44 Get Purchase Circle Products with Screen Scraping
    Hack 45 Find Purchase Circles by Zip Code
    Hack 46 Track the Ranks of Books Over Time
    Hack 47 Group Conversations About Books
    Hack 48 Add a 'Currently Reading' List to Your Web Site
    Chapter 4. Selling Through Amazon
    Chapter 5. Associates Program
    Chapter 6. Amazon Web Services
    Colophon
    Index


    More Books
    PHP Hacks
    Processing Xml With Java - A Guide To Sax, Dom, Jdom, Jaxp, And Trax
    The Koran (Holy Qur'an)
    Macromedia Flash 8 Bible
    Search Engine Optimization for Dummies
    YouTube Traffic
    PHP 5 for Dummies
    Harry Potter and The Chamber of Secrets
    Harry Potter and the Sorcerer's Stone
    The Pilgrim's Progress
    Wireless Hacks
    Flash Hacks. 100 Industrial-Strength Tips & Tools
    PayPal Hacks. 100 Industrial-Strength Tips and Tools
    Amazon Hacks
    Pdf Hacks
    The Da Vinci Code
    Google Hacks
    The Holy Bible
    Windows XP For Dummies
    Harry Potter and the Half-Blood Prince
    Seo Book
    Upgrading and Repairing Networks
    Macromedia Dreamweaver 8 UNLEASHED
    Windows XP Annoyances
    Windows XP Hacks
    Microsoft Windows XP Power Toolkit
    Teach Yourself MS Office In 24Hours
    iPod & iTunes Missing Manual
    PC Hacks 100 Industrial-Strength Tips and Tools
    PC Overclocking, Optimization, and Tuning - 2th Edition
    PC Hardware In A Nutshell 3rd Edition
    PC Hardware in a Nutshell, 2nd Edition
    Upgrading and Repairing PCs
    Google for Dummies
    MySQL Cookbook
    Teach Yourself Macromedia Flash 8 In 24 Hours
    PHP CookBook
    Sams Teach Yourself JavaScript in 24 Hours
    PHP5 Manual
    Free Games Paper Airplanes
    500 Juegos Gratis 500 Giochi Gratis 500 Jeux Gratuits 500 Jogos Gratis 500 Kostenlose Spiele