60199

Twitter oAuth is showing Invalid or expired token

Question:

I am trying to update some status in Twiiter by using oAuth. But when i try to connect to twitter it is showing in valid or expired token the exact message is

stdClass Object ( [errors] => Array ( [0] => stdClass Object ( [message] => Invalid or expired token [code] => 89 ) ) )

Why this error is showing? i am getting the token and token secret value in my session but it is showing error.

This is my php code.

<?php session_start(); define('OAUTH_CALLBACK', 'http://somedomain.com/twitter/index.php'); require_once('twitteroauth/twitteroauth.php'); if(!isset($_GET['oauth_token']) && !isset($_GET['oauth_verifier'])){ $connection = new TwitterOAuth('kvKZRppWiAKkMexUQTCSqA', 'tMK1QfjPFNmIMHcKM4YVAMenvzS31JWerhjAf4q8'); /*$account = $connection->get('account/verify_credentials'); print_r($account); $status = $connection->post('statuses/update', array('status' => 'Text of status here', 'in_reply_to_status_id' => 123456)); */ $temporary_credentials = $connection->getRequestToken(OAUTH_CALLBACK); $_SESSION['oauth_token'] = $token = $temporary_credentials['oauth_token']; $_SESSION['oauth_token_secret'] = $temporary_credentials['oauth_token_secret']; $redirect_url = $connection->getAuthorizeURL($temporary_credentials); header('Location:'.$redirect_url); //print_r($redirect_url); }else{ $oauth_token = $_SESSION['oauth_token']; $oauth_token_secret = $_SESSION['oauth_token_secret']; print $oauth_token; print $oauth_token_secret; $connection = new TwitterOAuth('kvKZRppWiAKkMexUQTCSqA', 'tMK1QfjPFNmIMHcKM4YVAMenvzS31JWerhjAf4q8',$oauth_token ,$oauth_token_secret); $account = $connection->get('account/verify_credentials'); print_r($account); }

Can anyone please help me?

Answer1:

You should check out this link may be this is the thing you are looking for

<a href="https://stackoverflow.com/questions/14502411/why-is-my-twitter-oauth-access-token-invalid-expired?rq=1" rel="nofollow">Why is my twitter oauth access token invalid / expired</a>

Recommend

  • Godaddy - SMTP Error(220-We do not authorize the use of this system to transport unsolicited, 220 an
  • default configuration change for SBT
  • Creating dynamic urls in codeigniter
  • php url shortening
  • Creating A New App For Page
  • Unable to generate call to cell phone using asterisk
  • Javascript/Jquery runs fast in desktop browsers, but slow in mobile/smartphone browsers…should I spl
  • CakePHP ACL tutorial initDB function warnings
  • How can I extract results of aggregate queries in slick?
  • Meteor helpers not available in Angular template
  • Exception “firebase.functions() takes … no argument …” when specifying a region for a Cloud Function
  • Using variable in a value field in jMeter
  • Debugging ASP.NET on a built-in web server suddenly stops
  • PHPUnit_Framework_TestCase class is not available. Fix… - Makegood , Eclipse
  • How to get a value (ex: baseURL) in every Karate feature?
  • Upload files with Ajax and Jquery
  • Do I've to free mysql result after storing it?
  • Rearranging Cells in UITableView Bug & Saving Changes
  • Numpy divide by zero. Why?
  • A cron job substitute?
  • InvalidAuthenticityToken between subdomains when logging in with Rails app
  • json Serialization in asp
  • log4net write single file for each call to log.info
  • Proper way to use connect-multiparty with express.js?
  • Benchmarking RAM performance - UWP and C#
  • Acquiring multiple attributes from .xml file in c#
  • Hits per day in Google Big Query
  • Angular 2 constructor injection vs direct access
  • FormattedException instead of throw new Exception(string.Format(…)) in .NET
  • How to CLICK on IE download dialog box i.e.(Open, Save, Save As…)
  • IndexOutOfRangeException on multidimensional array despite using GetLength check
  • Linking SubReports Without LinkChild/LinkMaster
  • How can I remove ASP.NET Designer.cs files?
  • XCode 8, some methods disappeared ? ex: layoutAttributesClass() -> AnyClass
  • How to get NHibernate ISession to cache entity not retrieved by primary key
  • costura.fody for a dll that references another dll
  • Observable and ngFor in Angular 2
  • UserPrincipal.Current returns apppool on IIS
  • Conditional In-Line CSS for IE and Others?
  • java string with new operator and a literal