Hack 29 Post a Review from a Remote Site

figs/moderate.giffigs/hack29.gif

To integrate adding Amazon reviews into a web publishing system or web site, examine the way Amazon posts information and create a remote copy.

Just as hundreds of sites are integrating with Amazon to provide product data and sales, there are many ways to tap into Amazon's community. If you'd like to integrate Amazon's review system into an existing site, you can do so with some simple HTML. By studying the HTML Amazon uses to submit reviews, you can create a generic form that sends reviews to Amazon from any site.

29.1 The Code

Create a file called remote_form.html containing the following code:

<html>
<head>
    <title>Remote Amazon Review</title>
</head>

<body>

<form method="POST" action="http://amazon.com /exec/obidos/preview-review/[RETURN]
insert ASIN /104-2773718-4336742">

<!-- Visible Form Fields -->
Rating:<br>
<select name=rating> 
    <option value="" selected>-</option> 
    <option value="5">5 stars</option> 
    <option value="4">4 stars</option> 
    <option value="3">3 stars</option> 
    <option value="2">2 stars</option> 
    <option value="1">1 star</option> 
</select>
<br><br>

Title:<br>
<input type="text" name="summary" value="" size=56 maxlength=60>
<br><br>
Review:<br>
<textarea wrap=virtual name="review" rows=9 cols=65></textarea>
<br><br>
Email:<br>
<input type=text name=email size=35 maxlength=250 value=" ">
<br><br>
Name:<br>
<input type=text name=source size=35 value="">
<br><br>
Show Name: 
<input type=radio name="display-email" value="SOURCE" checked><br>
Stay Anonymous: 
<input type=radio name="display-email" value="NO">
<br><br>
Location:<br>
<input type="text" name="user-location" value="" size=35 maxlength=120>

<!-- Hidden Form Fields -->
<input type=hidden name=secure-rate-review-next-page value=/exec/obidos/tg/[RETURN]
cm/review-thanks>
<input type=hidden name=store.store-name value="books">
<input type=hidden name=detail.this-asin value="insert ASIN ">
<input type=hidden name=detail.this-area value="customer-review-form">
<input type=hidden name=product.product-name  value="book_display_on_ [RETURN]
website ">
<input type="hidden" name="fp_ts" value="stores/detail/preview-customer-[RETURN]
review">
<input type="hidden" name="fe_ts" value="stores/detail">
<input type="hidden" name="priority" value=2500>

<!-- Submit Button -->
<br><br>
<input type="submit" value="Preview your review">
</form>

</body>
</html>

By now you're probably getting good at spotting ASINs [Hack #1], and there are two places you need to set the ASIN for the product you're reviewing. One spot is in the action attribute of the opening <form> tag, and the other is in a hidden form field called detail.this-asin.

There are several values possible for the product.product-name variable, and this needs to be set depending on the type of product you're reviewing. Here are a few examples of possible values:

  • book_display_on_website (books)

  • music_display_on_website (music)

  • classical_display_on_website (music)

  • ce_display_on_website (electronics)

  • dvd_display_on_website (dvd)

If an item you want to review doesn't fall into one of these categories, you can find the value by looking through Amazon's HTML. Bring up the review form, scan for the product.product-name field in the HTML, note its value, and include it in your version of the form.

29.2 Running the Hack

To add a review, just open remote_form.html anywhere, and write your review. Click the submit button to send the information to Amazon. You'll see your review on a preview page where you can double-check your review to make sure it is exactly what you want. Remember, there's no going back once it's submitted. If you want your review to be tied in with your Amazon ID and appear in your About You section [Hack #17], you'll want to be logged into Amazon when you send the review.