twitter oauth - 令牌无效或过期

时间:2013-01-27 03:49:06

标签: codeigniter twitter twitter-oauth

我正在使用simon的twitter库在代码点火器中使用twitter实现登录

这是代码

Twitter配置

$config['twitter'] = array(
'_tokens' => array(
    'consumer_key' => 'xxxxxxxxxxxxxxxxxxxxx',
    'consumer_secret' => 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
    //'access_key' => '',
    //'access_secret' => '',
),
'_force_login' => false, /* Do we force the user to login */
'_token_session' => 'twitter_oauth_tokens', /* Session name */
'_open_in_new_window' => true, /* Do links in Tweets get opened in a new window (add target="_blank" if true) */
'_new_window_target' => '_blank',
'_search_url' => 'http://twitter.com/search?q=%search%', /* Link for searches - '%search% is where the search key lives */
'_user_url' => 'http://twitter.com/%user%', /* Link for profiles - %user% is where the username lives */

/* Cache method (remember to make /applications/cache writable) or false for no caching */
'_cache_method' => array(
    'adapter' => 'apc',
    'backup' => 'file',
),
'cache_timeout' => 60, /* Timeout in seconds */

/* Most of these things shouldn't change */
'_access_token_url' => 'http://api.twitter.com/oauth/access_token',
'_api_url' => 'https://api.twitter.com/1.1/',
'_authorization_url' => 'http://api.twitter.com/oauth/authorize',
'_request_token_url' => 'http://api.twitter.com/oauth/request_token',
'_signature_method' => 'HMAC-SHA1',
'_version' => '1.0',
'_method' => 'json',
);

授权Twitter登录

public function index() {

    /* Check we're logged in */
    if($this->twitter->is_logged_in()) {
        /* We are */
        //$test = $this->twitter->get_username();
        //var_dump($test);
        //$url = 'account/verify_credentials';


        //$arrData = $this->twitter->call('get', 'account/verify_credentials');

        $user = $this->twitter->call('get', 'account/verify_credentials');
        var_dump($user); }

但是我得到以下错误

  

401 |请求失败{“错误”:[{“message”:“令牌无效或过期”,“代码”:89}]}

如何解决这个问题? 任何帮助都会被贬低......

1 个答案:

答案 0 :(得分:0)

你解决了这个问题吗? 在Twitter应用程序设置中重置您的消费者密钥/密钥,或 重新创建访问令牌可能有助于

同时检查Twitter OAuth - Invalid/Expired Token