Signing Amazon Webservices requests
MPoD is retrieving cover art for the currently playing song from Amazon the AWS (Amazon Web Services). From August 15 onwards, all requests made will have to be signed using a secret key that is attached to the registered AWSAccessKeyId. Searching on Google, I found various helpful bits, especially on the learn amazon web services blog. But I didn’t find a ready made implementation that I could use directly from my code.
Based on what I found I created a helper class AWSRequestSigner, that takes a dictionary of parameters to pass to the webservice, and returns a ready made NSURL object that can be used in an NSURLRequest object as in the following example:
NSURL *url = [AWSRequestSigner urlForParameterDict:[NSDictionary dictionaryWithObjectsAndKeys:
@"Sea Of Tears", @"Title",
@"Eilen Jewell", @"Artist",
@"ItemSearch", @"Operation",
@"Images", @"ResponseGroup",
@"Music", @"SearchIndex",
@"AWSECommerceService", @"Service",
nil]];
To look at the source code for the AWSRequestSigner class, download it here and open it in XCode.