What Amazon suggests, based on what I currently think is interesting (my Google Reader starred items and my del.icio.us links).
Data provided by Google Ajax Feed API and Amazon Associates API
There are three pieces to this: the javascript on this page which drives requests, a CGI running on my server which performs the Amazon request and execute an XSL Transform to create the images. Amazon can perform the transform on my behalf, which would be fine except that in this particular case, I wouldn't be able to invoke it from the browser, as that would amount to cross-site scripting. The other advantage is that I don't have to embed my associates key or AWS Access Key on the page that goes to the client, and I can control caching better, reducing the load on my own server as well as Amazon. The CGI is pretty straightforward Ruby:
#!/usr/local/bin/ruby
require 'cgi'
require 'net/http'
require 'xml/xslt'
cgi = CGI.new()
keywords = ''
if cgi.params['k'].kind_of? Array
keywords = cgi.params['k'].join(' or ')
else
keywords = cgi.params['k']
end
h = Net::HTTP.new("xml-us.amznxslt.com",80)
resp, data = h.get('/onca/xml?AssociateTag=XXXXXXX&Service=AWSECommerceService&AWSAccessKeyId=YYYYYYYYY&Operation=ItemSearch&SearchIndex=Books&ContentType=text%2Fhtml&ResponseGroup=Medium&Keywords=' + CGI.escape(keywords))
xslt = XML::XSLT.new()
xslt.xml = data
xslt.xsl = "xslt/xml-img.xsl"
cgi.out( "Expires" => CGI.rfc1123_date(Time.new + 86400),"Cache-Control" => "max-age=86400" ) {
xslt.serve()
}