title: Twitter OAuth : Invalid or expired token [its NOT duplicate]
body: <p>Before anyone goes in a hurry and mark this question as Duplicate, let me tell you that <strong>ITS NOT DUPLICATE</strong></p>
  
  <p>I have already checked similar question like <a href="https://stackoverflow.com/questions/14502411/why-is-my-twitter-oauth-access-token-invalid-expired">this</a>, <a href="https://stackoverflow.com/questions/15978333/why-is-the-twitter-oauth-access-token-invalid-expired-rails-3">this</a>, <a href="https://stackoverflow.com/questions/20441303/twitter-oauth-is-showing-invalid-or-expired-token">this</a> and <a href="https://stackoverflow.com/questions/17636701/twitter-api-reasons-for-invalid-or-expired-token">this</a>, but those are all 2 years old and the library has been changed too much since then so those answers are not useful.</p>
  
  <p>So here's the question. I'm using abraham's libraray which can be found <a href="https://github.com/abraham/twitteroauth" rel="nofollow noreferrer">here</a>.  Below is the code that I'm using:</p>
  
  <pre><code>if(!empty($_GET['oauth_verifier']) &amp;&amp; !empty($_SESSION['oauth_token']) &amp;&amp; !empty($_SESSION['oauth_token_secret']))
  {
      $connection = new TwitterOAuth('MY_CONSUMER_KEY', 'MY_CONSUMER_SECRET', $_SESSION['oauth_token'], $_SESSION['oauth_token_secret']);
  
      $access_token = $connection-&gt;oauth("oauth/access_token", array("oauth_verifier" =&gt; $_REQUEST['oauth_verifier']));
      $_SESSION['access_token'] = $access_token;
  
      $user_info = $connection-&gt;get("account/verify_credentials");
      print_r($user_info);
  }
  </code></pre>
  
  <p>From the <code>print_r</code> which I did above, I get the result as follows:</p>
  
  <pre><code>stdClass Object ( [errors] =&gt; Array ( [0] =&gt; stdClass Object ( [code] =&gt; 89 [message] =&gt; Invalid or expired token. ) ) )
  </code></pre>
  
  <p>Due to this <code>invalid/expired token</code> I'm not able to get ahead in my work. So I went 1 step back and did:</p>
  
  <pre><code>var_dump($access_token);
  </code></pre>
  
  <p>The result obtained is:</p>
  
  <pre><code>array(5) { 
     ["oauth_token"]=&gt; string(50) "*********" 
     ["oauth_token_secret"]=&gt; string(45) "*********" 
     ["user_id"]=&gt; string(10) "***My user id****" 
     ["screen_name"]=&gt; string(9) "***My screen name****" 
     ["x_auth_expires"]=&gt; string(1) "0" 
  }
  </code></pre>
  
  <p>Here you see that the last element is <code>["x_auth_expires"]</code> whose value is <code>0</code>. I think this element did not appear in the older version of the library. And I suppose this is the thing which is causing the problem.</p>
  
  <p>I tried re-generating my <code>Customer_Key</code> and <code>Customer_Secret</code>, but even that didn't seem to help.</p>
  
  <p>Any kind of help will be appreciated. Thank you.</p>