amazon product advertising api ruby signing requests
May 17, 2015
This week the marketing department at my company decided that they wanted to make a new landing page with a focus on social validation. Social validation means that the advertisement references other people who like the service in an effort to pursuade people that if the service works for these people then it might also work for them.
As part of this effort the marketing team wanted to show Amazon Product Reviews for a book that was written about our website. Normally I would just suggest copying a few reviews or taking a screenshot and pasting it, but recently Amazon.com began cracking down on this sort of behavior. My guess is that Amazon.com wants to manage the presentation of the data and get proper attribution links.
Thus, we needed to implement a programmatic way to query Amazon and get an iframe for displaying reviews on our landing page. Documentation for gettting user reviews can be found here. Notice that the link has a “RequestSignature” parameter. It turns out that the primary challenge to getting the api request to work is in calculating this signature. Luckily calculating this signature is well documented and I was able to come up with a solution. I broke out my trusty text editor and came up with this piece of code. Hopefully this saves you a couple minutes of your time so you can go back to drinking coffee and mingling at the water cooler.
For those of you developing a rails application this is how I ended up using the class in my controller.
Finally put the iframe on the page
This page changes but if you want to see an example of the final work, check it out.
I realize i’m mostly talking to myself on this blog but if anyone in on the interwebs finds this useful please leave a comment.