Authenticate REST requests to the Amazon Product Advertising API using Python

SowaCS Consulting’s Amazon Web Service Query Signer. Download the file called awsquerysigner_py.zip

As of August 15, 2009 Amazon required all API queries to have a special authentication signature. SowaCS Consulting has published a simple Python class (Python library?) that does the dirty work to sign your REST calls to the Amazon Product Advertising API. The code is on the website but they also offer a query signing service.

Back Story:

I finally got the gumption to attempt to tie in some AWS (Amazon Web Services) things into some of the websites I’m running because I want the affiliate advertising to blend in with my pages in a cleaner fashion. Unfortunately Amazon made it a lot harder for chumps like me to make API calls because of their newly enforced requirements that all requests be signed with a special hash signature. Steps involved to sign an Amazon REST request

  • Take query params, re-order them by byte-value and make them UTF-8.
  • url encode each key-value query parameter
  • replace any “+” and “~” characters in the strings with url encodings
  • add a timestamp
  • Build a text string to prepare for hashing
  • Encode signature using HMAC and SHA256
  • Send request, and receive REST response.

This process sounds easy, but I couldn’t figure it out. I wrestled with Amazon’s Product Advertising API Documentation but the examples mostly uninformative. Thankfully, I came across a helpful post in the developer forums that points to SowaCS consulting. Naturally when looking at the code theirs is much cleaner, more flexible and it actually works. It’s not superb code but it IS way better than anything I would ever write. I really ought to go back to school…

PS3 Media server for Mac is a good free DLNA server

PS3 Media Server is a worthwhile free (open source, free of charge) DLNA server that works on Mac, PC, and Linux. I found it easier to setup than Fuppes which is another free DLNA server. This is not an apples to apples comparison. I’m just saying if you have the choice, I would try tinkering with PS3 Media Server before trying Fuppes to see if it fits your needs.

Both servers have transcoding capabilities but I have not tried transcoding with either package yet because my computers do not have enough power to do transcode large/long files.

PS3 Media Server

If you are looking for a free DLNA server to run on a GUI on box, PS3 Media Server is a decent option. I have become a recent fan. PS3 Media Server (blog) is a Java program available via Google Code (download). I installed it on my Mac and I like the results. It installs like a regular Mac program with a .dmg package. You start the PS3 MS application and the PS3 DLNA should see the server right away. I don’t think I had to change any port configurations or anything like that. The one thing that I DID change was to configure PS3 MS to only look for music and media in 2 specific folders on my Mac.

Fuppes

Fuppes is my DLNA server on a crappy Ubuntu computer I built. Fuppes works fine but it is disappointing in a few ways. First, it was difficult to setup on Ubuntu. I had to pull the development version from the fuppes SVN repository to get something that would work on my Ubuntu distro. Second, my PS3 can take HOURS after running the database update before newly added media files appear on the PS3. The advantage of Fuppes is that it works on a headless server and it has a relatively convenient web-based configuration interface.

Using ImageCache with nginx

I couldn't get the ImageCache module for Drupal to work for the longest time because I didn't realize that the module came with a .htaccess file that pushes the image load back through Drupal to calculate the caching properly. Knowing this I was able to find this magical chunk for your nginx.conf (or your virtual host config). Slip this code in near the static serve file command

http://drupal.org/node/110224#comment-772191

# imagecache needs to have php read any files that it's planning to manipulate
location ^~ /sites/default/files/imagecache/ {
     index  index.php index.html;
     # assume a clean URL is requested, and rewrite to index.php                                                                 
      if (!-e $request_filename) {
          rewrite  ^/(.*)$  /index.php?q=$1  last;
          break;
      }
}
 
# serve static files directly
location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico)$ {
    access_log        off;
    expires           30d;
}

Syndicate content