--- amazon.php5.inc.orig	2009-07-27 16:21:12.000000000 -0400
+++ amazon.php5.inc	2009-08-12 21:18:13.000000000 -0400
@@ -19,12 +19,12 @@
    *
    */
   $_amazon_search_amazon_shop_URI =
-    array('US'=>'http://webservices.amazon.com/onca/xml?Service='.AMAZON_SEARCH_AMAZON_SERVICE,
-          'UK'=>'http://webservices.amazon.co.uk/onca/xml?Service='.AMAZON_SEARCH_AMAZON_SERVICE,
-          'DE'=>'http://webservices.amazon.de/onca/xml?Service='.AMAZON_SEARCH_AMAZON_SERVICE,
+    array('US'=>'http://ecs.amazon.com/onca/xml?Service='.AMAZON_SEARCH_AMAZON_SERVICE,
+          'UK'=>'http://ecs.amazon.co.uk/onca/xml?Service='.AMAZON_SEARCH_AMAZON_SERVICE,
+          'DE'=>'http://ecs.amazon.de/onca/xml?Service='.AMAZON_SEARCH_AMAZON_SERVICE,
           'JP'=>'http://webservices.amazon.co.jp/onca/xml?Service='.AMAZON_SEARCH_AMAZON_SERVICE,
-          'FR'=>'http://webservices.amazon.fr/onca/xml?Service='.AMAZON_SEARCH_AMAZON_SERVICE,
-          'CA'=>'http://webservices.amazon.ca/onca/xml?Service='.AMAZON_SEARCH_AMAZON_SERVICE
+          'FR'=>'http://ecs.amazon.fr/onca/xml?Service='.AMAZON_SEARCH_AMAZON_SERVICE,
+          'CA'=>'http://ecs.amazon.ca/onca/xml?Service='.AMAZON_SEARCH_AMAZON_SERVICE
           );
 
   /**
@@ -302,9 +302,39 @@
   */
   function amazon_get_XML($Amazon_Params) {
     $AmazonXML = '';
-    $url = amazon_search_RESTURI($Amazon_Params);
+   $url = amazon_search_RESTURI($Amazon_Params);
+   // This entire section handles signing the request.
+   // A Hack Indeed and The US is Hardcoded Into the Locale URL
+   // Add GMT timestamp - Required for Signing Request    
+   $Amazon_Params["Timestamp"] = gmdate("Y-m-d\TH:i:s\Z");
+   // Additional Parameters
+   $method = "GET";
+   $host = "ecs.amazonaws.com";
+   $uri = "/onca/xml";
+  
+   // sort the parameters
+   ksort($Amazon_Params);
+   // create the canonicalized query
+   $canonicalized_query = array();
+   foreach ($Amazon_Params as $param=>$value) {
+  		$param = str_replace("%7E", "~", rawurlencode($param));
+  		$value = str_replace("%7E", "~", rawurlencode($value));
+ 		$canonicalized_query[] = $param."=".$value;
+  		}
+ 	$canonicalized_query = implode("&", $canonicalized_query);
+   // create the string to sign
+   $string_to_sign = $method."\n".$host."\n".$uri."\n".$canonicalized_query;  
+   // calculate HMAC with SHA256 and base64-encoding
+   $secret_access_key=variable_get('amazon_aws_secret_access_key',"");
+   $signature = base64_encode(hash_hmac("sha256", $string_to_sign, $secret_access_key, True));  
+	// encode the signature for the request
+	$signature = str_replace("%7E", "~", rawurlencode($signature));
+  // create request
+  $url = "http://".$host.$uri."?".$canonicalized_query."&Signature=".$signature;
+   
     // Obviously this will be switched for an equivalent Drupal function
     // Nope. drupal_http_request() strips the doctype tag at the start of the XML, making it useless
+
     $ch = curl_init($url);
     curl_setopt($ch, CURLOPT_HEADER, 0);
     ob_start();
@@ -313,7 +343,6 @@
     curl_close($ch);
     return $AmazonXML;
   }
-
   /**
    * Returns a XML object with the result of the query.
    *
@@ -343,4 +372,4 @@
     return _amazon_items_array_from_DOM($_amazon_search_amazonDOM);
   }
 
-?>
\ No newline at end of file
+?>
