O'Reilly Hacks
oreilly.comO'Reilly NetworkSafari BookshelfConferences Sign In/My Account | View Cart   
Book List Learning Lab PDFs O'Reilly Gear Newsletters Press Room Jobs  


 
Buy the book!
Amazon Hacks
By Paul Bausch
August 2003
More Info

HACK
#29
Post a Review from a Remote Site
To integrate adding Amazon reviews into a web publishing system or web site, examine the way Amazon posts information and create a remote copy
The Code
[Discuss (1) | Link to this hack]

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 , 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.


O'Reilly Home | Privacy Policy

© 2007 O'Reilly Media, Inc.
Website: | Customer Service: | Book issues:

All trademarks and registered trademarks appearing on oreilly.com are the property of their respective owners.