River – Amazon Wishlist Gem

One more post on Amazon Wishlist code. As another follow up to my post on Amazon Wishlist RSS, Ruby and Signing/Authenticating your Requests and the site I built to run the code My Amazon Feeds (post here) I've created a gem to contain all the code. Get it by running

  sudo gem install river

It's a pretty simple gem so working with the code is also pretty easy to do:

am = AmazonRequest.new(amazon_access_key_id, amazon_secret_access_key, ecs_to_rss_wishlist, amazon_associate_tag)
results = am.get_amazon_feeds(username) # username needs to be the user's Amazon email
feeds = results.collect { |result| OpenStruct.new(:url => result, :title => 'Amazon Wishlist', :name => 'wishlist') }

Get amazon_access_key_id and amazon_secret_access_key from your AWS console. The amazon_associate_tag parameter is optional. Throw it in there if you want your Amazon associate information in the feed. May as well :-).

The one parameter that might be confusing is 'ecs_to_rss_wishlist'. This value is a url where the xslt transform lives. This has to be a public url. I've included a version in the gem. To get it into your Rails application you'll need to add this to the Rakefile in the root of your app:

require 'river/tasks'
Then sync the file into your app:

rake river:sync

After that you'll find the file in the public directory and you'll be able to access it with something like http://www.example.com/ecs_to_rss_wishlist.xslt