Amazon Links

Astute readers will notice that I now have Amazon related links (books, actually) on some entries (spun out of my Amazon’s Web Services post). Hopefully they’re not too intrusive; I have them limited to a max of three results right now, and they’ll only show up on blog entries that I specifically keyword.

All done with Amazon’s web services. It’s not completely automatic, since I have to keyword the entry, but it beats looking up items by hand. Using the web service interface is extremely easy; simply build a URL and send the request to Amazon, and you’ll get XML results. I’m using the excellent Snoopy PHP class for the communication piece, and PHP’s built in XML parsing (using expat) to extract the information I want from the XML.

Some tips, after trial-and-error: Use a “Power” search in the Amazon request, especially if you have multiple keyword sets. An example might look like:

Power=keywords:(web services) or (xml) or (http programming)

The regular “Keyword” search turns useless after four or five words, it seems, and the “TextStream” search returned totally random results.

I played around with have the results sorted by rating (“reviewrank”), but dropped this because I was finding that older editions of the same book (hardcover vs. paperback, for example) might have a higher rating, but not actually be available. By dropping the sorting entirely, Amazon returns surprisingly relevant results.

The results can include images, all hosted on Amazon’s servers. Use them! They come in three sizes.

And finally, pick your keywords carefully. Or you’ll get some weird, totally unrelated items.