2

I am trying to implement Twitter's OAuth into my Code Igniter web application at which the callback URL is /auth/ so once you have authenticated with Twitter you are taken to /auth/?oauth_token=SOME-TOKEN.

I want to keep the nice clean URL's the framework provides using the /controller/method/ style of URL but I want to enable query strings as well, there will only ever be one name of the data oauth_token so it's ok if it has to be hard coded.

Any ideas? I have tried tons of the things people are saying to do, but none work :( PS: I'm using the .htaccess method of URL rewriting.

tarnfeld
  • 25,992
  • 41
  • 111
  • 146

3 Answers3

6

There are several ways to handle this.

Most People, and Elliot Haughin's Twitter Lib, extend the CI_Input library with a MY_Input library that sets allow_query_strings to true

You will also need to add ? to the allowed characters in config/config.php and set $config['url_protocal'] to PATH_INFO

see here: Enable GET in CodeIgniter

Community
  • 1
  • 1
Zack
  • 2,846
  • 2
  • 22
  • 16
1

Codeigniter Reactor lets you access $_GET directly or via $this->input->get(). You don't need to use MY_Input or even change your config.php. This method leaves the query string in the URL, however.

David Xia
  • 5,075
  • 7
  • 35
  • 52
0

I used a hacked index.php to recognise users coming back from Twitter, check for valid and safe values, then re-direct it to to a CodeIgniter friendly URL.

It may not be to everyones taste but I preferred it over allowing query strings throughout the entire application instead of just one particular circumstance.

  • If you going to go that route, why not just have a separate PHP file that does a query string to URI segment conversion? I think that would be better than hacking up CI's index.php. – Zack May 15 '10 at 17:04
  • Yeah I guess, I just added a one line include to the php file that determines whether to intercept or not. –  May 15 '10 at 20:36