使用twitterapi刷新令牌

使用twitterapi刷新令牌,twitter,twitter-oauth,Twitter,Twitter Oauth,我想知道Twitter是否有一个API端点,可以将过期的访问令牌与活动令牌交换。我现在让登录流工作的方式是这样的 // Request a token and redirect to the authorization page $token = $this->twitter->getRequestToken(); // Set the session data $this->session->set_userdata('oauth_token', $token['oa

我想知道Twitter是否有一个API端点,可以将过期的访问令牌与活动令牌交换。我现在让登录流工作的方式是这样的

// Request a token and redirect to the authorization page
$token = $this->twitter->getRequestToken();

// Set the session data
$this->session->set_userdata('oauth_token', $token['oauth_token']);
$this->session->set_userdata('oauth_token_secret', $token['oauth_token_secret']);

// Redirect the user to the authorization page
header('Location: https://api.twitter.com/oauth/authorize?oauth_token='.$token['oauth_token']);
用户重定向到的页面将提示用户在每次需要有效访问令牌时授权我的应用。接受授权后,用户将被重定向到回调URL。在我的回调URL中,会发生以下情况

// Get the parameters from the URL
$token = $this->input->get('oauth_token');
$verifier = $this->input->get('oauth_verifier');

$oauthToken = $this->session->oauth_token;
$oauthSecret = $this->session->oauth_token_secret;

// Get the access token
$access = $this->twitter->getAccessToken($verifier, $oauthToken, $oauthSecret);
是否存在这样一种方式来生成访问令牌,而不必每次都授权我的应用程序

根据,令牌不会过期,除非用户明确拒绝您的应用程序或管理员暂停您的应用程序

如果您希望您的用户能够重复登录而无需重新授权,则需要提出一种存储令牌(cookie、数据库等)的机制