• 1 Vote(s) - 4 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Integrating twitterOauth?

#1
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
Reply

#2
(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?
Codeigniter is simply one of the tools you need to learn to be a successful developer. Always add more tools to your coding arsenal!
Reply

#3
could do I suppose. would that make it easier?
Reply

#4
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.
Codeigniter is simply one of the tools you need to learn to be a successful developer. Always add more tools to your coding arsenal!
Reply

#5
(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.
Reply

#6
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.
Reply

#7
(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.
Reply

#8
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
Reply

#9
(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/...-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";
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.