CodingForums.com

CodingForums.com (http://www.codingforums.com/index.php)
-   PHP (http://www.codingforums.com/forumdisplay.php?f=6)
-   -   Twitter API problem (http://www.codingforums.com/showthread.php?t=284928)

cloudstryphe 12-28-2012 02:07 AM

Twitter API problem
 
Hello. I built a website that interfaces with the Twitter API. Recently I decided to transfer my entire website onto a framework (codeigniter).

My issue is as follows.

In my Models I have the following

Code:

public function settwconfig(){
  $userid = $this->input->cookie("userid_cookie");
  $this->load->config("twitter");
  $this->load->library("TwitterOAuth");
               
  if($_SESSION['username'] == "" OR $_SESSION['username'] == NULL) {
               
        $sql = "SELECT * FROM `user_twtokens` WHERE `userid` = ?";
        $query = $this->db->query($sql, $userid);
       
        $row = $query->row();
                       
        $_SESSION['username'] = $row->username;
        $_SESSION['oauth_uid'] = $row->oauth_uid;
        $_SESSION['oauth_provider'] = $row->oauth_provider;
        $_SESSION['oauth_token'] = $row->oauth_token;
        $_SESSION['oauth_secret'] = $row->oauth_secret;
  }

               
$twitteroauth = new TwitterOAuth($this->config->item('twitter_consumer_token'), $this->config->item('twitter_consumer_secret'), $_SESSION['oauth_token'], $_SESSION['oauth_secret']);
               
return $twitteroauth;
})

I use this method to initialize Twitter then call it in another function where I make a call like such:
Code:

public function feed() {

  $twitteroauth = $this->settwconfig();
               
  $feed = $twitteroauth->get('statuses/home_timeline', array('count' => 25));
               
  return $feed;
})

When put in a view, the feed displays fine and I get all the tweets I want, but I get 4 errors saying that "Message: Missing argument 1 for TwitterOAuth::__construct()" and I have no idea why. The feeds are working fine but I don't understand how the class is errorirng out yet still giving me the feed.

The library I'm using is the following: https://github.com/abraham/twitteroauth

This has been killing me. All help is welcome :)

cloudstryphe 01-02-2013 06:18 AM

nobody? :(

madindo 02-02-2013 05:02 PM

Quote:

Originally Posted by cloudstryphe (Post 1302573)
Hello. I built a website that interfaces with the Twitter API. Recently I decided to transfer my entire website onto a framework (codeigniter).

My issue is as follows.

In my Models I have the following

Code:

public function settwconfig(){
  $userid = $this->input->cookie("userid_cookie");
  $this->load->config("twitter");
  $this->load->library("TwitterOAuth");
               
  if($_SESSION['username'] == "" OR $_SESSION['username'] == NULL) {
               
        $sql = "SELECT * FROM `user_twtokens` WHERE `userid` = ?";
        $query = $this->db->query($sql, $userid);
       
        $row = $query->row();
                       
        $_SESSION['username'] = $row->username;
        $_SESSION['oauth_uid'] = $row->oauth_uid;
        $_SESSION['oauth_provider'] = $row->oauth_provider;
        $_SESSION['oauth_token'] = $row->oauth_token;
        $_SESSION['oauth_secret'] = $row->oauth_secret;
  }

               
$twitteroauth = new TwitterOAuth($this->config->item('twitter_consumer_token'), $this->config->item('twitter_consumer_secret'), $_SESSION['oauth_token'], $_SESSION['oauth_secret']);
               
return $twitteroauth;
})

I use this method to initialize Twitter then call it in another function where I make a call like such:
Code:

public function feed() {

  $twitteroauth = $this->settwconfig();
               
  $feed = $twitteroauth->get('statuses/home_timeline', array('count' => 25));
               
  return $feed;
})

When put in a view, the feed displays fine and I get all the tweets I want, but I get 4 errors saying that "Message: Missing argument 1 for TwitterOAuth::__construct()" and I have no idea why. The feeds are working fine but I don't understand how the class is errorirng out yet still giving me the feed.

The library I'm using is the following: https://github.com/abraham/twitteroauth

This has been killing me. All help is welcome :)


I had the same problem... this is what I did...
In twitterauth it doesn't have a default value...

so from
function __construct($consumer_key, $consumer_secret, $oauth_token = NULL, $oauth_token_secret = NULL) {

to
function __construct($consumer_key = '', $consumer_secret = '', $oauth_token = NULL, $oauth_token_secret = NULL) {

Solved :)


All times are GMT +1. The time now is 03:03 PM.

Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.