Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 12-28-2012, 02:07 AM   PM User | #1
cloudstryphe
New Coder

 
Join Date: Mar 2012
Posts: 62
Thanks: 7
Thanked 0 Times in 0 Posts
cloudstryphe is an unknown quantity at this point
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..
cloudstryphe is offline   Reply With Quote
Old 01-02-2013, 06:18 AM   PM User | #2
cloudstryphe
New Coder

 
Join Date: Mar 2012
Posts: 62
Thanks: 7
Thanked 0 Times in 0 Posts
cloudstryphe is an unknown quantity at this point
nobody?
cloudstryphe is offline   Reply With Quote
Old 02-02-2013, 05:02 PM   PM User | #3
madindo
New to the CF scene

 
Join Date: Feb 2013
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
madindo is an unknown quantity at this point
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
madindo is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


Advertisement
Log in to turn off these ads.