php - Twitter OAuth : Invalid or expired token [its NOT duplicate] -
before goes in hurry , mark question duplicate, let me tell its not duplicate
i have checked similar question this, this, this , this, 2 years old , library has been changed since answers not useful.
so here's question. i'm using abraham's libraray can found here. below code i'm using:
if(!empty($_get['oauth_verifier']) && !empty($_session['oauth_token']) && !empty($_session['oauth_token_secret'])) { $connection = new twitteroauth('my_consumer_key', 'my_consumer_secret', $_session['oauth_token'], $_session['oauth_token_secret']); $access_token = $connection->oauth("oauth/access_token", array("oauth_verifier" => $_request['oauth_verifier'])); $_session['access_token'] = $access_token; $user_info = $connection->get("account/verify_credentials"); print_r($user_info); }
from print_r
did above, result follows:
stdclass object ( [errors] => array ( [0] => stdclass object ( [code] => 89 [message] => invalid or expired token. ) ) )
due invalid/expired token
i'm not able ahead in work. went 1 step , did:
var_dump($access_token);
the result obtained is:
array(5) { ["oauth_token"]=> string(50) "*********" ["oauth_token_secret"]=> string(45) "*********" ["user_id"]=> string(10) "***my user id****" ["screen_name"]=> string(9) "***my screen name****" ["x_auth_expires"]=> string(1) "0" }
here see last element ["x_auth_expires"]
value 0
. think element did not appear in older version of library. , suppose thing causing problem.
i tried re-generating customer_key
, customer_secret
, didn't seem help.
any kind of appreciated. thank you.
finally, found solution.
all need is, once callback, initialize class again new access token.
$connection = new twitteroauth('my_consumer_key', 'my_consumer_secret', $_session['oauth_token'], $_session['oauth_token_secret']); $access_token = $connection->oauth("oauth/access_token", array("oauth_verifier" => $_request['oauth_verifier'])); $connection = new twitteroauth('my_consumer_key', 'my_consumer_secret', $access_token['oauth_token'], $access_token['oauth_token_secret']);
i don't know why works, work charm. found solution here.
Comments
Post a Comment