Welcome Guest, Not a member yet? Register   Sign In
Stuck in a authorisation loop - Haughin's Twitter Library
#1

[eluser]Shodan[/eluser]
Hi there,

I'm trying to get Elliot Haughin's Twiiter library up and running and am having problems almost straight away.

I'm simply trying to run the example code that comes with the library but for some reason it seems to go into some sort of redirect loop between my app and Twitter.

The home.php controller is unmodified (other than I've added my consumer key etc.) and it never seems to get past line 36:

Code:
$auth = $this->twitter->oauth($consumer_key, $consumer_key_secret, $tokens['access_token'], $tokens['access_token_secret']);

I've followed the instructions on this page of his site but I'm guessing I've either missed something or it's an issue with my host.

Does anyone have any ideas?

Cheers,
Terry
#2

[eluser]Hrag[/eluser]
So your callback url is pointing back to your home.php in your application settings? (http://twitter.com/apps for convenience).

Wondering how it's looping if it doesn't get past line 36?

Best,
Hrag
#3

[eluser]Eric_WVGG[/eluser]
I'm also having this issue. Definitely have the correct callback url.
#4

[eluser]Eric_WVGG[/eluser]
I think I just figured it out. The library depends on a subclass override (MY_Input.php), which is part of the process that safely enables _GET variables.

CodeIgniter automatically subclasses system files (like Input.php) using a "subclass prefix" (defined in your config.php). When it sees MY_Input.php in your application/library, it subclasses Input.php with that functionality.

My subclass prefix is set to XX_. I renamed MY_Input.php to XX_Input.php, and edited line 16 to read: "class XX_Input extends CI_Input {". The Twitter library appears to be working now.
#5

[eluser]Shodan[/eluser]
Glad you got it sorted dude.

Unfortunately, my subclass prefix is already 'MY_' so it should working.

Still going round in circles, anyone got any ideas?
#6

[eluser]Brandon Beasley[/eluser]
The library is somewhat outdated, since most of the API methods have changed and it doesn't support lists or geo-location features. I am in the process of writing a new wrapper/CI library for EpiTwitter which will fix all of the broken Twitter methods in Elliot's library. You can track the progress of this project on my website.
#7

[eluser]Shodan[/eluser]
OK, i'm going to add some more details here in the hope that someone can help!

I don't seem to be able to hit pretty URLs directly anymore. Whenever I try to access the following link for instance:

http://www.example.com/test/home, I get:

No input file specified.

Here's my .htaccess:

Code:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /test/
#Removes access to the system folder by users.
#Additionally this will allow you to create a System.php controller,
#previously this would not have been possible.
#’system’ can be replaced if you have renamed your system folder.
RewriteCond %{REQUEST_URI} ^@codeigniter.*
RewriteRule ^(.*)$ /index.php/$1 [L]

#Checks to see if the user is attempting to access a valid file,
#such as an image or css document, if this isn't true it sends the
#request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
# If we don’t have mod_rewrite installed, all 404’s
# can be sent to index.php, and everything works as normal.
# Submitted by: ElliotHaughin
ErrorDocument 404 /index.php
</IfModule>

I've updated my config.php like so:

Code:
$config['uri_protocol']    = "PATH_INFO";

and so:

Code:
$config['permitted_uri_chars'] = 'a-z? 0-9~%.:_\-';

I've set the default controller in my routes.php to "home". home.php being the controller that came with Elliot Haughin's library.

The callback URL for my app in twitter is

http://www.example.com/test/

which produces the redirect looping I described in the original post.

Setting it to http://www.example.com/test/home results in the no input specified error.

My server is running PHP5.2. If I try and force to run php4, I can hit the URLs but I get a php parsing error in the home controller.

Cheers,
Terry
#8

[eluser]joelg[/eluser]
Hi Shodan,

Did you make any more progress with this? I'm currently going through the exact same issue and I'm trying to solve it but I thought I'd ask here too in case I don't get it fixed before you respond. If I do, I'll be sure to update the thread.

I've been looking around and so far the closest I think I got to solving it was when I found this in another thread about accessing $_GET in CodeIgniter 2.0:

Quote:Are you using CI 1.7.2 or 2.0? I just started playing with 2.0 and found that extending classes that normally reside in ./system/core apparently need to go in ./application/core for example I always extend the Controller class, so I have ./application/core/MY_Controller.php.

Now to continue battling with it Smile
#9

[eluser]joelg[/eluser]
Well, I just sussed it out.

I delved into the core Input library and found a difference in the variable name of the allow_get_array variable:

In the previous code suggested to get things working, we had as follows:

Code:
class MY_Input extends CI_Input {

    function _sanitize_globals()
    {
        $this->allow_get_array = TRUE;
        parent::_sanitize_globals();
    }
    
}

whereas with CodeIgniter 2.0 it seems that the variable is named $this->_allow_get_array (notice the extra underscore):

Code:
class MY_Input extends CI_Input {

    function _sanitize_globals()
    {
        $this->_allow_get_array = TRUE;
        parent::_sanitize_globals();
    }
    
}

That solved it for me.




Theme © iAndrew 2016 - Forum software by © MyBB