Content Management
MTAmazon 2.0
Freshness Warning
This blog post is over 22 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:
- related (Optional)
Related can only be used if the MTAmazon tags are used on an individual archive or inside the
<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 (Required unless related is used)
The search keywords, ASIN, artist, or other search string to use. You can separate multiple search words with spaces. You can use the contents of any other MT tag as the search string by enclosing the other tag name in square brackets. For instance, to use an entry’s title as the search string, you would usesearch="[MTEntryTitle]"
. - associateid (optional)
The Amazon Associate ID to use. Using an Associate ID will allow Amazon.com to give you credit for any sales that you send their way. If you don’t specify an Associate ID, Kalsey Consulting Group’s Associate ID will be used. You can set a default Associate ID by changing the line at the top of amazon.pl that readsmy $default_associateid = "kalsey-20";
and replacing "Kalsey-20" with your associate ID. - devtoken (Required)
The Amazon.com developer’s token. Amazon requires this token in order to track who is using their Web services. You can apply for one for free at http://amazon.com/webservices/. You’ll need to provide them with your name and address and accept a license agreement. You can set a default developer’s token by changing the line at the top of amazon.pl that readsmy $default_devtoken = "";
and place your developer’s token inside the quotes. - method (optional)
The search method to use. Defaults to Keyword. Valid values are: Keyword, Upc, Asin, Author, Director, Actor, Artist, Manufacturer, ListMania, Similar, BrowseNode, search, browse. You can find out more about search methods at http://amazon.com/webservices/. "browse" means the same thing as BrowseNode and "search" means the same thing as Keyword. These are included for backward compatibility with older versions of MTAmazon. - line (optional)
The Amazon product line to search. Defaults to books. Valid product lines are:
- baby (Baby)
- books (Books)
- classical (Classical Music)
- dvd (DVD)
- electronics (Electronics)
- garden (Outdoor Living)
- kitchen (Kitchen & Housewares)
- magazines (Magazines)
- music (Popular Music)
- pc-hardware (Computers)
- photo (Camera & Photo)
- software (Software)
- toys (Toys & Games)
- universal (Tools & Hardware)
- vhs (Video)
- videogames (Computer & Video Games)
- lastn (optional)
The maximum products to retrieve. Defaults to 10. Valid values are the numbers 0-10.
<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.
- Attributes:
- glue (Optional)
Some books have more than one author. You can use theglue
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.
- Attributes:
- glue (Optional)
Some music has more than one artist. You can use theglue
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.
- Attributes:
- name (Optional)
The name of the Amazon XML field you would like to display.
<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