title: oauth signature Invalid - Smugmug - PHP - cURL
body: <p>I am getting OAUTH signature invalid error. Can someone please check what am I doing wrong. Below is my PHP Code, I ran through lot of docs and auth bible website too but below code is not working ! please help !!! I have removed my key and secret for security reasons.</p>
  
  <p>=============================================================</p>
  
  <pre><code>   $host = "https://secure.smugmug.com/services/oauth/1.0a/getRequestToken?";
     $path            = ""; 
     $request_method  = "GET";
     $consumer_key    = "mykey";
     $consumer_secret = "mysecret";
  
  
     //collect the data (as an associative array)
     $oauth_data = array(
        'oauth_consumer_key'     =&gt; $consumer_key,
        'oauth_nonce'            =&gt; (string)mt_rand(), // a stronger nonce is recommended
        'oauth_signature_method' =&gt; 'HMAC-SHA1',
        'oauth_timestamp'        =&gt; time(),
        'oauth_callback'     =&gt; "http://mywebsite/callback",
        'oauth_version'          =&gt; '1.0'
     );
  
  
     $arr = array();
  
     //normalize the parameters - apply url encoding separately to each key/value pair
     foreach($oauth_data AS $key =&gt; $value)  {
        $encoded_key = rawurlencode($key);
        $encoded_val = rawurlencode($value);
        $arr[$encoded_key] = $encoded_val;
     }
  
     //normalize the parameters - sort the encoded data by key
     ksort($arr);
  
     //normalize the parameters - list the data members as string in &lt;key&gt;=&lt;value&gt; format and insert "&amp;" between each pair
     // http_build_query automatically encodes, but our parameters are already encoded, 
     // so we urldecode to prevent double-encoding
     $querystring = urldecode(http_build_query($arr, '', '&amp;'));
  
     //normalize the parameters - apply urlencoding to the resulting string
     $encoded_query_string = rawurlencode($querystring);
  
  
   $url = $host;
  
     // mash everything together for the text to hash
     $base_string = strtoupper($request_method). "&amp;". rawurlencode($url).       "&amp;". $encoded_query_string;
  
  
     $key = rawurlencode($consumer_secret)."&amp;";
  
     // generate the hash
     $signature = rawurlencode(base64_encode(hash_hmac('sha1', $base_string, $key, true)));
  
  
     $url = $host . "&amp;" . $querystring . "&amp;oauth_signature=" . $signature;
  
  
      //  Initiate curl
    $ch = curl_init();
  
   // Disable SSL verification
  
  
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);  
   // Will return the response, if false it print the response
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
   // Set the url
  curl_setopt($ch, CURLOPT_URL,$url);
    //curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type:  application/json')); 
  
     curl_setopt($ch, CURLOPT_HEADER, 1);
  
   curl_setopt($ch, CURLOPT_HTTPHEADER, array('Accept: application/json'));  
  
   $result=curl_exec($ch); 
  
   // Will dump a beauty json :3
  
   print_r($result);
  
   curl_close($ch); 
  </code></pre>