title: Calculate HMAC-SHA1 Signature
body: <p>I got the code below in PHP but getting a error from my server that am not authorised so am prob doing something wrong in calculation of the $signature for the oauth_signature field.</p>
  
  <p>Am not setting any HTTP headers.</p>
  
  <pre><code>        include_once "oauth-php/library/OAuthStore.php";
          include_once "oauth-php/library/OAuthRequester.php";
  
          $key = 'xx'; // this is your consumer key
          $secret = 'xx'; // this is your secret key
          $req_url = "http://www.sample.com"; 
  
          $options = array( 'consumer_key' =&gt; $key, 'consumer_secret' =&gt; $secret);
  
      OAuthStore::instance("2Leg", $options );
  
      $method = "POST";  
  </code></pre>
  
  <p>$params = array(
                          'oauth_consumer_key' => $key, 
                          'oauth_signature_method' => 'HMAC-SHA1',
                          'oauth_timestamp' => time(),
                          'oauth_nonce' => time(),
                          'user_id' => '1234'
                          );</p>
  
  <pre><code>    $post_string = ''; 
  foreach($params as $key =&gt; $value) {
          $post_string .= $key.'='.($value).'&amp;'; 
  } 
  $post_string = rtrim($post_string, '&amp;'); 
  $base_string = urlencodeRFC3986($post_string); 
  $signature = base64_encode(hash_hmac('sha1', $base_string, $secret, true));
  
  $params['oauth_signature'] = $signature;
  try {
              $request = new OAuthRequester($req_url, $method, $params);
  
              $result = $request-&gt;doRequest();
              var_dump($result); 
  } 
  catch(OAuthException2 $e)
  {   
  var_dump($e); 
  }
  
  function urlencodeRFC3986($string) 
  {    
  return str_replace('%7E', '~', rawurlencode($string)); 
  }
  </code></pre>