codebird-php icon indicating copy to clipboard operation
codebird-php copied to clipboard

Fatal error: Call to a member function oauth_requestToken() on null in C:\xampp\htdocs\logintwitter\app\TwitterAuth.php on line 21

Open PerezLopezRoberto opened this issue 7 years ago • 2 comments

I am working on twitter sign-up on my web application and I have an issue that I am not quite sure what the problem is.

-----------TwitterAuth.php-----------

`
class TwitterAuth{

protected $cliente;
protected $clienteCallback = "http://127.0.0.1/logintwitter/callback.php";

public function _construct(\Codebird\Codebird $cliente){
	$this->cliente = $cliente;		
}

public function getAuthUrl(){
	$this->requestTokens();
	$this->verifyTokens();
	
	return $this->cliente->oauth_authenticate();
}

public function requestTokens(){	

	$reply = $this->cliente->oauth_requestToken([
	'oauth_callback' => $this->clienteCallback
	]);		
	
	$this->storeTokens($reply->oauth_token, $reply->oauth_token_secret);
	
}

protected function storeTokens($token,$tokenSecret){
	$_SESSION['oauth_token'] = $token;
	$_SESSION['oauth_token_secret'] = $tokenSecret;
}

public function verifyTokens(){
	$this->cliente->setToken($_SESSION['oauth_token'],$_SESSION['oauth_token_secret']);
}

public function isLogin(){
	return false;
}

}`

-----------init.php-----------

` session_start();

require_once('vendor/autoload.php'); require_once('app/TwitterAuth.php');

\Codebird\Codebird::setConsumerKey('xxxxxxxx','xxxxxxxxxxxxxxxx');

$cliente = \Codebird\Codebird::getInstance();`

-----------index.php-----------

`require_once('app/init.php');

$auth = new TwitterAuth($cliente);

if($auth->isLogin()){ echo "

Esta en el sistema. Cerrar Sesion

"; }else{ echo $auth->getAuthUrl(); }`

PerezLopezRoberto avatar Apr 07 '18 06:04 PerezLopezRoberto

hello, u solved that ? my Codebird::getInstance(); return null

lepfsd avatar May 15 '18 22:05 lepfsd

@Lepfsd Can you tell me more details about your null return value?

mynetx avatar Oct 28 '18 14:10 mynetx