CodeIgniter Forums
Integrating twitterOauth? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: Integrating twitterOauth? (/showthread.php?tid=64861)



Integrating twitterOauth? - blackbulldog - 04-04-2016

Hi,

Been away for a while so a bit rusty (rustier). Looking to integrate the twitter oauth app as found at twitterouath.com and am not sure how to do it as it' not just one single php file.

Anyone help?
Thanks


RE: Integrating twitterOauth? - albertleao - 04-04-2016

(04-04-2016, 08:42 AM)blackbulldog Wrote: Hi,

Been away for a while so a bit rusty (rustier). Looking to integrate the twitter oauth app as found at twitterouath.com and am not sure how to do it as it' not just one single php file.

Anyone help?
Thanks

Are you using composer?


RE: Integrating twitterOauth? - blackbulldog - 04-04-2016

could do I suppose. would that make it easier?


RE: Integrating twitterOauth? - albertleao - 04-04-2016

If you're using composer, copy and pasting the directions on the landing page of twitteroauth.com will make it work. Just make sure you're using the correct namespace for the twitteroauth library, I don't remember if it's namespaced or not.


RE: Integrating twitterOauth? - blackbulldog - 04-05-2016

(04-04-2016, 04:37 PM)albertleao Wrote: If you're using composer, copy and pasting the directions on the landing page of twitteroauth.com will make it work. Just make sure you're using the correct namespace for the twitteroauth library, I don't remember if it's namespaced or not.

ok, I'm happy using composer I think - I'd have to install it in the 'libraries' folder, that right - to do the install but I have no idea how to load the library once installed ... i think it is namespaced so that confused things even more for a dope like me.

any help with the install and loading is greatly appreciated.


RE: Integrating twitterOauth? - Tpojka - 04-05-2016

If you are using composer, with default CI3 settings there will be created additional vendor directory in root location
(that's where you need to put composer.json file also). Calling new classes in your controller would be like:

PHP Code:
<?php
defined
('BASEPATH') OR exit('No direct script access allowed');

use 
Abraham\TwitterOAuth\TwitterOAuth;

class 
Welcome extends CI_Controller
{
    public function 
__construct()
    {
    
parent::__construct();
        
        
$connection = new TwitterOAuth(CONSUMER_KEYCONSUMER_SECRET$access_token$access_token_secret);
        
$content $connection->get("account/verify_credentials");
    }


To make this work you need to set option to true or custom path. More docs
 Link for composer.json file. Rest of docs for twitteroauth use.


RE: Integrating twitterOauth? - blackbulldog - 04-05-2016

(04-05-2016, 04:43 AM)Tpojka Wrote: If you are using composer, with default CI3 settings there will be created additional vendor directory in root location
(that's where you need to put composer.json file also). Calling new classes in your controller would be like:

PHP Code:
<?php
defined
('BASEPATH') OR exit('No direct script access allowed');

use 
Abraham\TwitterOAuth\TwitterOAuth;

class 
Welcome extends CI_Controller
{
 
   public function __construct()
 
   {
 
parent::__construct();
 
       
        $connection 
= new TwitterOAuth(CONSUMER_KEYCONSUMER_SECRET$access_token$access_token_secret);
 
       $content $connection->get("account/verify_credentials");
 
   }


To make this work you need to set option to true or custom path. More docs
 Link for composer.json file. Rest of docs for twitteroauth use.

Thank you I've been tearing my hair out over this.
Your solution, with a slight tweak, worked perfectly.
Moving the composer.json to the vendor folder and running the require command form inside that folder mean that the 'update' worked fine. But it created and installed all the files to a sub-folder called vendor. So I had a directory structure that looked like this:

vendor->vendor

and the code above didn;t work.

Moving all the files from the sub-folder called vendor into the higher level vendor folder seemed to do the rtrck and the code works just fine.

Thanks again.


RE: Integrating twitterOauth? - raulrola - 01-12-2018

Hi... Instead of opening a new thread I'm asking here because I would like to know how to implement twittteroauth WITHOUT using Composer. I mean, with codeigniter downloaded as the manual suggest. Is it possible? Maybe using third_party directory? Thank you


RE: Integrating twitterOauth? - raulrola - 01-12-2018

(01-12-2018, 07:30 AM)raulrola Wrote: Hi... Instead of opening a new thread I'm asking here because I would like to know how to implement twittteroauth WITHOUT using Composer. I mean, with codeigniter downloaded as the manual suggest. Is it possible? Maybe using third_party directory? Thank you

Ok I'm ansering myself since I solved it. It was really simple following the instructions from here: https://github.com/abraham/twitteroauth/issues/586#issuecomment-352299580

I downloaded the last version from github and extracted it at third_party directory.

Then, I just needed to put this before the class declaration
Code:
use Abraham\TwitterOAuth\TwitterOAuth;

And this inside my method code:
Code:
require "twitteroauth/autoload.php";