Twitter登录Codeigniter与elliothaughin /给出错误

时间:2012-11-13 15:51:19

标签: php codeigniter twitter-oauth

尝试在codeigniter中使用Twitter进行身份验证。它转到twitter并返回,但是给出了错误。这是错误和代码。有提示吗?

A PHP Error was encountered
Severity: Notice
Message: Undefined property: stdClass::$request
Filename: libraries/tweet.php
Line Number: 205

A PHP Error was encountered
Severity: Notice
Message: Undefined property: stdClass::$error
Filename: libraries/tweet.php
Line Number: 205

bool(false)

A PHP Error was encountered
Severity: Notice
Message: Undefined variable: friendship
Filename: controllers/tweet_connect.php
Line Number: 63

这是代码;

function index()
    {
        echo 'hi there';
    }

  function auth()
  {
    $tokens = $this->tweet->get_tokens();

    // $user = $this->tweet->call('get', 'account/verify_credentiaaaaaaaaals');
    // 
    // Will throw an error with a stacktrace.

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

    //$friendship   = $this->tweet->call('get', 'friendships/show', array('source_screen_name' => $user->screen_name, 'target_screen_name' => 'elliothaughin'));
    //var_dump($friendship);

    if ( $friendship->relationship->target->following === FALSE )
    {
    //$this->tweet->call('post', 'friendships/create', array('screen_name' => $user->screen_name, 'follow' => TRUE));
    }

    //$this->tweet->call('post', 'statuses/update', array('status' => 'Testing #CodeIgniter Twitter library by @elliothaughin - http://bit.ly/grHmua'));

    $options = array(
    'count' => 10,
    'page'  => 2,
    'include_entities' => 1
    );

    //$timeline = $this->tweet->call('get', 'statuses/home_timeline');

    //var_dump($timeline);
  }

1 个答案:

答案 0 :(得分:1)

您可能正在使用旧库:https://github.com/elliothaughin/codeigniter-twitter/pull/25#commitcomment-1988684

您可能已达到请求限制:Elliot Haughin API verify credentials error

自从lib大约2年前发布以来,twitter api也发生了很多变化 - lib可能在当前状态下不再起作用。

可能想查看twitter提供的图书馆:https://dev.twitter.com/docs/twitter-libraries#php