Welcome Guest, Not a member yet? Register   Sign In
j7mbo/twitter-api-php via composer and CI4
#1

Hi.
I installed, via composer, the j7mbo twitter api, and followed all the code I found online but with no luck.
I always have the same error: "Class 'App\Controllers\TwitterAPIExchange' not found"
No matter if I put on Autoload in classmap the following:
PHP Code:
$classmap = [
            
'TwitterAPIExchange' => ROOTPATH.'/vendor/j7mbo/twitter-api-php',
        ]; 

and call it on my Controller with the following code:

PHP Code:
    $twitem = new CommunicationsModel();
        $twsettings = array (
          $twsetaccesstoken $twitem->getTweetConfig('twitter_accesstoken'),
          $twsettokensecret $twitem->getTweetConfig('twitter_tokensecret'),
          $twsetapikey $twitem->getTweetConfig('twitter_apikey'),
          $twsetkeysecret $twitem->getTweetConfig('twitter_secretkey')
        );
        $twurl 'https://api.twitter.com/1.1/statuses/update.json';
        $twmethod 'POST';
        $twfields = array (
          'status'=>'New Game added to DB! '.$data['name'].' https://stdb.games/game/'.$data['slug']
        );
        $tweet = new TwitterAPIExchange($twsettings);
        $tweet->buildOauth($twurl$twmethod)
              ->setPostfields($twfields)
              ->performRequest(); 

Anyone can put me in the right direction?
Thanks a lot!
Reply
#2

(This post was last modified: 08-14-2020, 02:52 PM by jreklund.)

Put a forward slash in front of it.

From:
Code:
$tweet = new TwitterAPIExchange($twsettings);

Into:
Code:
$tweet = new \TwitterAPIExchange($twsettings);

You don't need to put in the classmap, composer will find it for you.
Reply
#3

(08-14-2020, 02:51 PM)jreklund Wrote: Put a forward slash in front of it.

From:
Code:
$tweet = new TwitterAPIExchange($twsettings);

Into:
Code:
$tweet = new \TwitterAPIExchange($twsettings);

You don't need to put in the classmap, composer will find it for you.

Thank you it works now! Thank you very much!
Reply
#4

(08-15-2020, 10:11 AM)jolupa Wrote: Thank you it works now! Thank you very much!

You're welcome. Happy coding!
Reply




Theme © iAndrew 2016 - Forum software by © MyBB