This is the blog of Adam Kalsey. Unusual depth and complexity. Rich, full body with a hint of nutty earthiness.
Freshness Warning
This blog post is over 20 years old. It's possible that the information you read below isn't current and the links no longer work.
25 Jul 2002
Note: MTAmazon now has its own site hosted at Source Forge. The most recent versions and documentation can be found there.
MTAmazon is a Movable Type plugin that uses your Amazon Associate membership to retrieve products from Amazon. It allows flexible searching and display of products from any of Amazon’s product categories.
The plugin uses Amazon’s Web services toolkit to search for products by keyword, product category, artist, author, and more. Search results are cached for one hour to improve rebuilding performance on busy sites.
New in version 2.0 is the ability to automatically search for products related to your blog entries. You can use one of the special "related" keywords, or use the contents of any MT tag in your search.
Download. You can get MTAmazon by visiting the download page.
Requirements. In order to use MTAmazon, you’ll need to be running Movable Type 2.21 or later and have two Perl modules installed: XML::Simple and LWP::UserAgent. Both are common modules, so there’s a good chance your server has them installed.
When you rebuild your templates, MTAmazon will automatically check to see if these modules are installed on your server. If they aren’t already on your server, you can download and install them by copying them to Movable Type’s extlib directory.
To install LWP:UserAgent, please follow the instructions in the Movable Type documentation.
To install XML::Simple, download XMLModules.zip and unzip it. Upload the entire XML directory to your extlib directory inside Movable Type.
Installation. Once you’ve downloaded and unzipped MTAmazon.zip, connect to your FTP server and open the directory where you have Movable Type installed.
Create a directory there called plugins if there isn’t one already and copy amazon.pl to the plugins directory.
Create another directory inside your Movable Type directory called cache if there isn’t one already. Set the permissions on this directory to 666. This is the directory where the cache files are stored. If you use a lot of different searches that change often, you may find that this directory ends up with a large number of files in it. If this concerns you, all of the files in the cache directory can be periodically deleted without causing any harm. MTAmazon will recreate any cache files it needs.
Using MTAmazon. Once you’ve installed MTAmazon, You’ll have a set of new Movable Type tags. Use these in your template to display products from Amazon.com.
Available tags.Any of the following tags can be used:
<MTAmazon >
<MTAmazon >
is the container tag that executes a search returns the results. All other product-related tags must be placed within this container. MTAmazon accepts the following attributes:
<MTEntries>
container. You can use any one of the following values for this attribute: category, title, extended, or excerpt. If this attribute is present, then the contents of the entry’s title, extended text, category, or excerpt will be is used as the search string.
search="[MTEntryTitle]"
.
my $default_associateid = "kalsey-20";
and replacing "Kalsey-20" with your associate ID.
my $default_devtoken = "";
and place your developer’s token inside the quotes.
<MTAmazonTitle >
The title or name of the product.
<MTAmazonASIN >
Amazon’s product code for the product. This can be useful when setting up shoping cart links.
<MTAmazonCatalog >
The Amazon product category for the product.
<MTAmazonManufacturer >
The name of the product manufacturer or publisher.
<MTAmazonAuthor >
The name of a book’s author. If the product is not from the books line, this tag will contain nothing.
glue
attribute to specify what separator to use in the list of authors. Defaults to ", "<MTAmazonArtist >
The name of the music artist. If the product is not from the music line, this tag will contain nothing.
glue
attribute to specify what separator to use in the list of artists. Defaults to ", "<MTAmazonImage >
This tag is being retired and is included for backward compatibility reasons. This returns the same image as <MTAmazonMediumImage >
.
<MTAmazonSmallImage >
The small thumbnail image for the product.
<MTAmazonMediumImage >
The medium size image for the product.
<MTAmazonLargeImage >
The large image for the product.
<MTAmazonSalePrice >
Amazon’s price. If this is blank, it means that Amazon’s price is so low that it can’t be advertised. A shopper must actually add the product to their Amazon.com shopping cart before seeing it’s price.
<MTAmazonListPrice>
The manufacturer’s suggested, or list, price.
<MTAmazonUsedPrice>
The used price from Amazon Auctions and zShops.
<MTAmazonReleaseDate>
The date that the item was released. You can use MT’s date tag formatting to format this the way you would like. None of the dates include times, so if you use any time values in your formatting, the time is treated as 12:00 am. Some Amazon products do not have a day of the month included with the release date, so even if your date format specifies a day, it won’t be shown for those products.
<MTAmazonLink>
The URL of the product. This includes your affiliate code if you specified one in your search.
<MTAmazonCacheDateTime>
The date and time when the cache was last updated. If the cache is new, the current date and time are returned. You can use MT’s date tag formatting to format this the way you would like.
<MTAmazonField >
A special tag that returns the value of any field in the Amazon XML document. This can be used to support any additional fields that Amazon may add to their XML document without having to wait for another release of MTAmazon.
<MTAmazonAssociateID >
The Amazon Associate id that was used in the search. This is primarily useful in constructing links to add items to an Amazon shopping cart or wish list.
<MTAmazonDevToken >
The Amazon developer’s token that was used in the search. This is primarily useful in constructing links to add items to an Amazon shopping cart or wish list.
Example.
<MTAmazon method="Keyword" search="bowie" line="music" lastn="3">
<p><a href="<MTAmazonLink>">
<img src="<MTAmazonSmallImage>" align="left" border="0"><MTAmazonTitle>
</a><br>
<MTAmazonReleaseDate format="%B %e, %Y"><br>
Price: <MTAmazonSalePrice></p><br clear=all>
</MTAmazon>
Last updated: <MTAmazonCacheDateTime>
How to search There are many different Amazon product searches available to you. You can search using the methods Keyword, BrowseNode, Upc, Asin, Author, Director, Actor, Artist, Manufacturer, ListMania, or Similar. For each of these searches, you place your search terms in the MTAmazon search attribute.
Keyword. Keyword searches let you specify a list of search terms just as you would type them into the search box on Amazon.com. Multiple search words can be separated by spaces.
BrowseNode. BrowseNode allows you to return just about any list of products you see anywhere on Amazon.com. You can display best sellers, featured products, or all the products from one of their product categories. To use BrowseNode, you’ll need Amazon’s Browse ID for the category you which to display. To get the Browse ID, start browsing for products on Amazon. Once you’ve gotten to the category or product list you want to display, look in the address bar of your browser. You’ll see something like http://www.amazon.com/exec/obidos/tg/browse/-/408126/ref=br_dh_1_dah/002-8226029-7182418
. The browse ID for this category (DVD Awards) is highlighted in bold. The portion you’ll need is the number after browse/-/
.
Upc. UPC searches allow you to return a specific product or a list of products. Currently, Amazon.com only has UPC information for their music and classical categories, so using this type of search in any other category will return no results. If you want to find more than one UPC, you can separate the UPCs with commas.
Asin. An ASIN is Amazon.com’s product number. By searching using Asin, you can get a list of specific products from Amazon. You can separate multiple ASINs with commas.
Author. Author searches let you retrieve a list of books by a certain author. Since only books have authors, using an author search on any other product line will return no results.
Director. Director searches allow you to retrieve a list of movies by a particular director. Director searches can only be performed on the dvd, vhs, and video product lines. Using another product line along with a director search will not return any products.
Actor. Actor searches allow you to retrieve a list of movies staring a particular actor or actress. Actor searches can only be performed on the dvd, vhs, and video product lines. Using another product line along with an actor search will not return any products.
Artist. Searching by artist will retrieve a list of products by an artist or musician. Artists only exist for music and classical categories, so using this type of search in any other category will return no results.
Manufacturer. This allows you to search for all products made by a particular company. Manufacturer searches only work for the electronics, kitchen, videogames, software, photo, and pc-hardware categories, so using this search in any other product line will return no results.
ListMania. ListMania lists are created by Amazon.com customers and usually appear on the right-hand side of the search results. These lists are usually lists of related products compiled by an Amazon.com customer, such as "Best Classic Horror Films" or "Favorite Children’s Books."
To display a ListMania list on your site, you’ll need the ListMania list id. Once you are on the page that contains the list you want to display, look in the address bar of your browser. You’ll see something like http://www.amazon.com/exec/obidos/tg/listmania/list-browse/-/2559R61E9FYYD/qid=1027657648/sr=5-2/ref=sr_5_2/104-6326920-4934352
. The list ID for this list (Great Indoor Games) is highlighted in bold. The portion you’ll need is the number after list-browse/-/
, 2559R61E9FYYD.
Similar. A popular Amazon.com feature is the "Customers who bought this also bought..." lists. To display a list of similar products for any particular product, all you need to do is use the Similar search method and the product’s ASIN for the search string.
See it. Visit these sites to see MTAmazon in action:
Acknowledgements. Thanks to Brad Choate for contributing some of the code for MTAmazon. Also thanks to the many people who tested beta versions of the plugin and who used the first version and provided feature suggestions.
License. Like our other freeware, this plugin is released under the open-source MIT License. In plain English, that means you can do whatever you want with the software, including modifying it, selling it, or eating it, but we’re not responsible for anything that goes wrong.
Revision History
2.01 - July 26, 2002
(Fix) MTAmazonAuthor and MTAmazonArtists displays count instead of names
(Fix) MTAmazonReleaseDate displays 0000 for many release dates.
2.0 - July 25, 2002
(New) Support for the new Amazon web services format, including many new tags.
(New) Search results are cached for faster rebuilding.
(New) Related searches are allowed through a new related attribute.
(New) Search strings can be the contents of any Movable Type tag.
1.0 - July 14, 2002
Initial public release
*sigh* I see all kinds of brackets were converted. Oh well, I fixed one thing: By setting the permissions of the cache to 776, I got rid of the "MT::App::CMS=HASH(0x81eb094) print() on closed filehandle MT::CACHE at plugins/amazon.pl line 335.", but I'm still getting the "MT::App::CMS=HASH(0x81eb094) Use of uninitialized value in concatenation (.) at [..]/lib/MT/Builder.pm line 76." error. I use a repetition of 4 tags, each with a different search string. I notice it is saved ok in the cache folder. (Btw, this did work well in the first version of MTAmazon.)
My apologies! I didn't see that the newest version is hosted somewhere else. Version 2.0.2 solved my problem. So, please ignore or delete my previous comments.
Could you please give some functional examples, with their output?
I've posted three sample templates along with the output they produce at http://kalsey.com/blog/2002/08/mtamazon_sample_templates.stm
It is probably my faulty understanding of MT plugin functionality, but... is there a way to use MTAmazon tags in the text of posts, and not in the templates? Judging by the existence of text formatting plugins, it seems that processing of actual entry contents is possible...
MT does not process tags inside entry text. It doesn't even look to see if any are there. Text formatting plugins work differently. The MT engine passes the text through the foratting plugin before writing it to the page. The only way to get MT to process tags is through the use of my process tags plugin: http://kalsey.com/2002/08/process_tags_plugin/ Make sure you read the security concerns with the plugin at http://kalsey.com/2002/08/process_tags_security_update/
Thanks! I really appreciate the advice and the effort gone into your plugins. By the way, there is a typo on the process_tags plugin page ( http://kalsey.com/2002/08/process_tags_plugin/ ), where it names process_plugins attribute instead of the correct (shown just below) process_tags. Perhaps this can deconfuse someone when fixed :)
Is there a similar tool for blogger?
Excerpt: I'm having a bit of a play around with the MTAmazon plugin....
Is 3.0 ever going to come out?
Excerpt: A massive thanks to heyblog for a most elegant MT-Amazon workaround that has finally allowed me to start updating my...
Hi ... trying to install MTAmazon for the first time and MT isn't picking up the plugin. I have BookQueueToo installed which appears in the plugin list fine. When I click on that plugin I get the error: "An error occurred: Your server does not have MTPlugins::MTAmazon installed, or MTPlugins::MTAmazon requires another module that is not installed. MTPlugins::MTAmazon is required. Please consult the installation instructions for help in installing MTPlugins::MTAmazon" XML::Simple (v2.14) and LWP::UserAgent (v2.001) are both installed. amazon.pl and .mtamazon.config are in the plugins folder and MTAmazon.pm is in the extlib folder. Am I missing something? Thanks. GC.
hi, would it be possible to use this plugin to get all the product reviews for a particular REVIEWER at amazon, not by product?
Can i know the "Suggested Tags from Similar Products" Xml FIeld Name for Amazon AWs API.
These are the last 15 comments. Read all 26 comments here.
This discussion has been closed.
Adriaan Tijsseling
August 4, 2002 5:40 AM
I'm getting the same error: Build error in template 'Main Index': Error in tag: Error in tag: close go back MT::App::CMS=HASH(0x81eb094) print() on closed filehandle MT::CACHE at plugins/amazon.pl line 335. MT::App::CMS=HASH(0x81eb094) print() on closed filehandle MT::CACHE at plugins/amazon.pl line 335. MT::App::CMS=HASH(0x81eb094) print() on closed filehandle MT::CACHE at plugins/amazon.pl line 335. MT::App::CMS=HASH(0x81eb094) Use of uninitialized value in concatenation (.) at [..]/lib/MT/Builder.pm line 76. I have the cache in the right directory (directly under the MT dir). My template contains the following array: random amazon list " target="_top">, , " target="_top">, " target="_top">, , " target="_top">, , Can you help me out here?