jublo / codebird-php

Easy access to the Twitter REST API, Direct Messages API, Account Activity API, TON (Object Nest) API and Twitter Ads API — all from one PHP library.
https://www.jublo.net/projects/codebird/php
GNU General Public License v3.0
776 stars 234 forks source link

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

Open PerezLopezRoberto opened 6 years ago

PerezLopezRoberto commented 6 years ago

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(); }`

lepfsd commented 6 years ago

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

mynetx commented 5 years ago

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