title: Amazon Product API returns "SignatureDoesNotMatch"
body: <p>I want to write app for get book covers through ISBN (for charity programme). So I decided to use Amazon product API. I got access key and secret key. I got a code for generate secret key I passed URL but that returns like that</p>
  <pre><code>&lt;?xml version=&quot;1.0&quot;?&gt;
  &lt;ItemLookupErrorResponse xmlns=&quot;http://ecs.amazonaws.com/doc/2005-10-05/&quot;&gt;
  &lt;Error&gt;&lt;Code&gt;SignatureDoesNotMatch&lt;/Code&gt;&lt;Message&gt;The request signature we calculated
  does not match the signature you provided. 
  Check your AWS Secret Access Key and signing method. 
  Consult the service documentation for details.     
  &lt;/Message&gt;&lt;/Error&gt;&lt;RequestID&gt;6c60b8b7-8b78-4f21-bb7c-3d5d3a26dc48&lt;/RequestID&gt;
  &lt;/ItemLookupErrorResponse&gt;
  </code></pre>
  <p>that's code</p>
  <pre><code>&lt;?php
  $AWSAccessKeyId = &quot;*******ACCESS KEY***************&quot;;
  
  
  
      $signature = base64_encode(hash_hmac('sha256',$string_to_sign,&quot;******SECRET KEY*******&quot;,true));
      // encode any plus (+), equal (=), or other reserved characters in $signature
      $signature = str_replace('%7E','~',rawurlencode($signature));
  
      $url = &quot;http://ecs.amazonaws.com/onca/xml?AWSAccessKeyId=&quot;.$AWSAccessKeyId.&quot;&amp;IdType=ASIN&amp;ItemId=1933988355&amp;Operation=ItemLookup&amp;ResponseGroup=Medium%2COffers&amp;Service=AWSECommerceService&amp;Timestamp=&quot;.gmdate('Y-m-d\TH:i:s\Z').&quot;&amp;Signature=&quot;.$signature;
  
  echo $url;
  ?&gt;
  </code></pre>
  <p>what's the problem that code?</p>
  <h3>Update:</h3>
  <p>I tried using same time stamp. Still no luck. That's sample code.</p>
  <pre><code>$method = &quot;GET&quot;;
  $host = &quot;ecs.amazonaws.&quot;.$region;
  $uri = &quot;/onca/xml&quot;;
  
  // additional parameters
  $params[&quot;Service&quot;] = &quot;AWSECommerceService&quot;;
  $params[&quot;AWSAccessKeyId&quot;] = $public_key;
  // GMT timestamp
  $params[&quot;Timestamp&quot;] = gmdate(&quot;Y-m-d\TH:i:s\Z&quot;);
  // API version
  $params[&quot;Version&quot;] = &quot;2009-03-31&quot;;
  
  // sort the parameters
  ksort($params);
  
  // create the canonicalized query
  $canonicalized_query = array();
  foreach ($params as $param=&gt;$value)
  {
      $param = str_replace(&quot;%7E&quot;, &quot;~&quot;, rawurlencode($param));
      $value = str_replace(&quot;%7E&quot;, &quot;~&quot;, rawurlencode($value));
      $canonicalized_query[] = $param.&quot;=&quot;.$value;
  }
  $canonicalized_query = implode(&quot;&amp;&quot;, $canonicalized_query);
  
  // create the string to sign
  $string_to_sign = $method.&quot;\n&quot;.$host.&quot;\n&quot;.$uri.&quot;\n&quot;.$canonicalized_query;
  
  // calculate HMAC with SHA256 and base64-encoding
  $signature = base64_encode(hash_hmac(&quot;sha256&quot;, $string_to_sign, $private_key, True));
  
  // encode the signature for the request
  $signature = str_replace(&quot;%7E&quot;, &quot;~&quot;, rawurlencode($signature)); 
  </code></pre>