Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Mar 2012
    Posts
    63
    Thanks
    7
    Thanked 0 Times in 0 Posts

    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
    Last edited by cloudstryphe; 12-28-2012 at 02:09 AM.

  • #2
    New Coder
    Join Date
    Mar 2012
    Posts
    63
    Thanks
    7
    Thanked 0 Times in 0 Posts
    nobody?

  • #3
    New to the CF scene
    Join Date
    Feb 2013
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by cloudstryphe View Post
    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


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •