Twitter OAuth: There is no request token for this page

admin

Administrator
Staff member
I'm using Abraham's
Code:
TwitterOAuth
library to implement Twitter OAuth in my application. However, on clicking the
Code:
Login
button, users are sometimes redirected to the following page:

<a href=" " rel="nofollow noreferrer"><img src=" " alt="enter image description here"></a>

I said 'sometimes', because sometimes the Twitter OAuth provider does generate the request token, and the users are taken to the 'Grant Permission' page.

Is this a library issue? Or is this an issue with the Twitter OAuth provider? If there was an issue with my code, then this page should appear every time a user tries to login using his/her Twitter account, and not at random tries.

Here's the code of the template that the users are redirected to after clicking the
Code:
Login
button:

Code:
&lt;?php

/*
 *Template Name: OAuth

*/

?&gt;

&lt;pre&gt;

&lt;?php

    session_start();
    require "twitteroauth/autoload.php";
    use Abraham\TwitterOAuth\TwitterOAuth;

    define('CONSUMER_KEY', "XXXXXXXXXXXXXXX");
    define('CONSUMER_SECRET', "XXXXXXXXXXXXXXXXXXXX");
    define('OAUTH_CALLBACK', "http://localhost/wordpress/index.php/callback/");

    $connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET);
    $request_token = $connection-&gt;oauth('oauth/request_token', array('oauth_callback' =&gt; OAUTH_CALLBACK));
    $_SESSION['oauth_token'] = $request_token['oauth_token'];
    $_SESSION['oauth_token_secret'] = $request_token['oauth_token_secret'];

    $url = $connection-&gt;url('oauth/authorize', array('oauth_token' =&gt; $request_token['oauth_token']));

    header('Location: '.$url);
?&gt;

&lt;/pre&gt;

PS: I also tried regenerating the
Code:
Consumer Key
and
Code:
Consumer Secret
, but that doesn't seem to have solved the problem.