title: The request signature we calculated does not match the signature you provided. Check your AWS Secret Access Key and signing method in php
body: <p>I have check my access key and secret key so many time and it correct
  i want to call use the route53 api in my project to show the available domain to user
  it show me error
  {&quot;__type&quot;:&quot;InvalidSignatureException&quot;,&quot;message&quot;:&quot;The request signature we calculated does not match the signature you provided. Check your AWS Secret Access Key and signing method&quot;}</p>
  <pre><code>
      $method = 'POST';
      $service = 'route53domains';
      $host = 'route53domains.us-east-1.amazonaws.com';
      $region = 'us-east-1';
      $endPoint = 'https://route53domains.us-east-1.amazonaws.com';
  
      $content_type = 'application/x-amz-json-1.0';
  
      $x_amz_target = &quot;Route53Domains_v20140515.GetDomainSuggestions&quot;;
  
      $request_parameter = '{';
      $request_parameter += '&quot;DomainName&quot;:&quot;pharmacy.com&quot;,';
      $request_parameter += '&quot;SuggestionCount&quot;:20,';
      $request_parameter += '&quot;OnlyAvailable&quot;:true';
      $request_parameter += '}';
  
      $amz_date = date('Ymd');
      $time = date('H:i:s');
     
      $zz = &quot;20211002T124804Z&quot;;
      
      // echo $amz;
      $canonical_path = &quot;/&quot;;
      $canonical_query = &quot;&quot;;
  
      $canonical_header = &quot;content-type:&quot;.$content_type.'\n'.'host:'.$host.'\n'.'x-amz-date:'.$zz.'\n'.'x-amz-target:'.$x_amz_target.'\n';
  
      $signed_header = 'content-type;host;x-amz-date;x-amz-target';
  
      $payload_hash = bin2hex(hash(&quot;sha256&quot;,base64_encode($request_parameter)));
  
      // echo $payload_hash;
      // exit;
      $canonical_request = $method.'\n'.$canonical_path.'\n'.$canonical_query.'\n'.$canonical_header.'\n'.$signed_header.'\n'.$payload_hash;
  
      $algo = &quot;AWS4-HMAC-SHA256&quot;;
      $crendential_scope = $amz_date.'/'.$region.'/'.$service.'/'.'aws4_request';
  
      $stringToSign =$algo.'\n'.$amz_date.'\n'.$crendential_scope.'\n'.bin2hex(hash(&quot;sha256&quot;,base64_encode($canonical_request)));
  
      $key = &quot;AWS4 g6j3nITVxvjbXamKLxxxxxxxxxxxxx&quot;;
      $keyhs = bin2hex(hash_hmac('sha256',base64_encode($key),$amz_date));
      $region = bin2hex(hash_hmac('sha256',base64_encode($keyhs),'us-east-1'));
      $keyReg = bin2hex(hash_hmac('sha256',base64_encode($region),'route53domains'));
      $sing = bin2hex(hash_hmac('sha256',base64_encode($keyReg),'aws4_request'));
  
  
      $sg = bin2hex(hash_hmac(&quot;sha256&quot;,$sing,hash(&quot;sha256&quot;,base64_encode($stringToSign))));
  
          // hash()
      print_r($sg);
      echo &quot;&lt;br&gt;&quot;;
  
  
  
  $curl = curl_init();
  
  curl_setopt_array($curl, array(
    CURLOPT_URL =&gt; 'https://route53domains.us-east-1.amazonaws.com',
    CURLOPT_RETURNTRANSFER =&gt; true,
    CURLOPT_ENCODING =&gt; '',
    CURLOPT_MAXREDIRS =&gt; 10,
    CURLOPT_TIMEOUT =&gt; 0,
    CURLOPT_FOLLOWLOCATION =&gt; true,
    CURLOPT_HTTP_VERSION =&gt; CURL_HTTP_VERSION_1_1,
    CURLOPT_CUSTOMREQUEST =&gt; 'POST',
    CURLOPT_POSTFIELDS =&gt;'{
      &quot;DomainName&quot;: &quot;dawaishop.com&quot;,
      &quot;SuggestionCount&quot;:20,
      &quot;OnlyAvailable&quot;:true
  }',
    CURLOPT_HTTPHEADER =&gt; array(
      'Authorization: AWS4-HMAC-SHA256 Credential=AKIATDHV27SBXXXXXX/'.$crendential_scope.',SignedHeaders=content-type;host;x-amz-date;x-amz-target,Signature='.$sg,
      'x-amz-target: Route53Domains_v20140515.GetDomainSuggestions',
      'Content-Type: application/x-amz-json-1.1',
      'x-amz-date:'.$zz
    ),
  ));
  
  $response = curl_exec($curl);
  
  echo &quot;&lt;pre&gt;&quot;;
  print_r($response);
  curl_close($curl);
  // echo $response;
  
  
  
  ?&gt;
  </code></pre>