Getting an unexpected response trying to do oAuth


I am using the Abraham WIllaism twitterOAuth library, downloaded a couple of days ago. Here’s my code:

$connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET);
$request_token = $connection->getRequestToken(OAUTH_CALLBACK);
$_SESSION['oauth_token'] = $token = $request_token['oauth_token'];
$_SESSION['oauth_token_secret'] = $request_token['oauth_token_secret'];
switch ($connection->http_code) {
  case 200:
    $url = $connection->getAuthorizeURL($token);
    print "<script>self.location='$url';</script>";

The resulting $url here is:
The problem is that when I re-direct to this url, here’s what I get in response: %09http//acme_app/twitter/index.php?oauth_token=xxxxxxxx&oauth_verifier=xxxxxxx
where http//acme_app/twitter/index.php is my callback URL
along with a message from Firefox telling me that it cannot find the server at:

Am I doing something wrong? I check the API status, but there are no listed issues.


It sounds like your oauth_callback value is being over-escaped – I’d look at the code you’re using to set the callback and verify that you’re letting the OAuth code encode it once on the request token step.


(please note code in question):
If you include some statements before line #8 to print out the session as well as $request_token and $url, here’s what I get:

[oauth_token] => xxxxxxxxx
[oauth_token_secret] => xxxxxxx

[oauth_token] => xxxxxxxxx
[oauth_token_secret] => xxxxxxxxxx
[oauth_callback_confirmed] => true

If I run the URL, I get the following: %09http//

Which is the same thing I am getting when I re-direct from the code, but in this case, I’m running the url manually, so there is no code involved, but I’m still getting this. Any ideas?


What is the raw value you are sending to oauth/request_token as the oauth_callback parameter?


define (‘OAUTH_CALLBACK’,‘http//acme_app/twitter/index.php’);


That’s not a valid URL – URLs need to have a colon between the protocol and the slashes like “http://acme_app/twitter/index.php”