Okay, this is the result of var_dumping the curl_getinfo() function:

array(21) {
  ["url"]=>
  string(38) "http://twitter.com/oauth/request_token";
  ["content_type"]=>
  string(24) "text/html; charset=utf-8"
  ["http_code"]=>
  int(401)
  ["header_size"]=>
  int(723)
  ["request_size"]=>
  int(346)
  ["filetime"]=>
  int(-1)
  ["ssl_verify_result"]=>
  int(0)
  ["redirect_count"]=>
  int(0)
  ["total_time"]=>
  float(0.458)
  ["namelookup_time"]=>
  float(0.052)
  ["connect_time"]=>
  float(0.053)
  ["pretransfer_time"]=>
  float(0.053)
  ["size_upload"]=>
  float(0)
  ["size_download"]=>
  float(21)
  ["speed_download"]=>
  float(45)
  ["speed_upload"]=>
  float(0)
  ["download_content_length"]=>
  float(21)
  ["upload_content_length"]=>
  float(0)
  ["starttransfer_time"]=>
  float(0.458)
  ["redirect_time"]=>
  float(0)
  ["request_header"]=>
  string(346) "POST /oauth/request_token HTTP/1.1
Host: twitter.com
Accept: */*
Authorization: OAuth oauth_consumer_key=wZxfqwxtMvuRRGzSwHA3g,
oauth_signature_method=HMAC-SHA1, oauth_timestamp=1237666858,
oauth_nonce=c425ab39f5e7861c5edad12dd11704b36c638d31,
oauth_signature=MTg1NmY3ZDVjMGRlYWY2N2FiYWQyNmZlZGEyOThkODUxZDRiMjdiMA%3D%3D

Content-Length: 0

"
}

And this is the result I'm getting (including headers):

HTTP/1.1 401 Unauthorized
Date: Sat, 21 Mar 2009 20:20:58 GMT
Server: hi
Last-Modified: Sat, 21 Mar 2009 20:20:58 GMT
Status: 401 Unauthorized
Pragma: no-cache
Cache-Control: no-cache, no-store, must-revalidate, pre-check=0,
post-check=0
Content-Type: text/html; charset=utf-8
Content-Length: 21
Expires: Tue, 31 Mar 1981 05:00:00 GMT
X-Revision: 333cdceddc18c616210896e03f6189c74e4d081b
X-Transaction: 1237666858-19589-32718
Set-Cookie:
_twitter_sess=BAh7BzoHaWQiJTA3OGMzZDg5N2E3N2JmM2U5MjZmOWYwNTQ1MWNlOTA4Igpm%2
50AbGFzaElDOidBY3Rpb25Db250cm9sbGVyOjpGbGFzaDo6Rmxhc2hIYXNoewAG%250AOgpAdXNl
ZHsA--d446151272affa48dde27a80620af479319e1a76; domain=.twitter.com; path=/
Vary: Accept-Encoding
Connection: close

Invalid OAuth Request

As you can see from the former output the headers are being sent properly,
so I've got no idea why it's not working. Here is the function which builds
the signature:

private function sign_request($method, $url, $params) {
     
     //Method is fine, so straight onto URL
     $url = rawurlencode($url);
     
     //Handle the request parameters
     natsort($params);
     
     foreach ($params as $key => $value) {
       $params[$key] = rawurlencode($value);
     }
     
     $params = implode("&", $params);
     
     //Concat them all
     $base_string = $method . "&" . $url . "&" . $params;
     
     switch ($this->signature_method) {
       
       case 'HMAC-SHA1':
           $str = sha1($base_string);
           $str = base64_encode($str);
           $str = rawurlencode($str);
           
           return $str;
         break;
       case 'PLAINTEXT':
           return rawurlencode($this->shared_secret . "&" .
$this->token_secret);
         break;
     }
   }

The method being used is HMAC-SHA1.

Thanks!

Jamie

Jamie Rumbelow Designer / Developer / Writer / Speaker
http://www.jamierumbelow.net | +44 (0)7956 363875 | jamie (at) jamierumbelow
(dot) net


-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Cameron
Kaiser
Sent: 21 March 2009 20:27
To: [email protected]
Subject: [twitter-dev] Re: Invalid oAuth Request


> I'm having a little trouble with oAuth - I'm getting an Invalid OAuth
> Request with a HTTP 401. I'm sure the signature is correct, and all
> I'm trying to do is get a request token. Has anyone had this problem
> before and if so how did you fix it?

Code and/or output is always helpful.

-- 
------------------------------------ personal: http://www.cameronkaiser.com/
--
  Cameron Kaiser * Floodgap Systems * www.floodgap.com *
[email protected]
-- If there was a hole, I would jump into it. -- Gackt Camui
------------------
No virus found in this incoming message.
Checked by AVG - www.avg.com 
Version: 8.0.238 / Virus Database: 270.11.20/2013 - Release Date: 03/20/09
19:01:00

Reply via email to