Note that there are some explanatory texts on larger screens.

plurals
  1. POanother twitter oAuth cURL access token request that fails
    text
    copied!<p>The following function gives a validation error instead of the token:</p> <blockquote> <p><em>failed to validate oAuth signature and token</em></p> </blockquote> <pre><code> function request_token() { // Set url $url = $this-&gt;site.$this-&gt;request_token_path; // http://api.twitter.com/oauth/request_token // Params to pass to twitter and create signature $params['oauth_consumer_key'] = $this-&gt;consumerKey; $params['oauth_token'] = ''; $params['oauth_nonce'] = SHA1(time()); $params['oauth_timestamp'] = time(); $params['oauth_signature_method'] = $this-&gt;signatureMethod; // HMAC-SHA1; $params['oauth_version'] = $this-&gt;version; // 1.0 ksort($params); //print "&lt;pre&gt;"; print_r($params); print "&lt;/pre&gt;"; // Create Signature $concatenatedParams = ''; foreach($params as $k =&gt; $v){ $concatenatedParams .= "{$k}={$v}&amp;"; } $concatenatedParams = substr($concatenatedParams,0,-1); $signatureBaseString = "POST&amp;".urlencode($url)."&amp;".urlencode($concatenatedParams); $params['oauth_signature'] = base64_encode(hash_hmac('SHA1', $signatureBaseString, $this-&gt;secret."&amp;", TRUE)); // Do cURL $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLINFO_HEADER_OUT, 0); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect:')); curl_setopt($ch, CURLOPT_HEADER, 1); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $params); curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); curl_setopt($ch, CURLOPT_FOLLOWLOCATION,1); $exec = curl_exec ($ch); $info = curl_getinfo($ch); curl_close ($ch); print $exec; //print "&lt;pre&gt;"; print_r($info); print "&lt;/pre&gt;"; } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload