views:

412

answers:

4

Hi all,

I'm having (many, but for now,) one problem with a project I'm working on.

  1. It is a PHP project run on Code Igniter
  2. It is a Facebook app that wants to use oAuth Twitter authorization

CodeIgniter by default clears the $_GET array because it uses the URI for controlling MVC stuff. You can turn this off to access the GET array, and use a string like example.com/?c=MyController&m=MyMethod to get around this.

Facebook asks you to define a root url for you application page. This means that for me:

apps.facebook.com/MyApplication == http://www.myownserver.com/index.php/c=SignIn&

I have it set up this way so that it can use the $_GET array. When Twitter (and I assume any other implementation) uses oAuth, it passes back to whatever URL you want with the ?token=250937602736037609273609327 appended onto the end, so I end up at

app.facebook.com/MyApplication/?token=302870637602746094276097

which looks right, but is in fact equivalent to

http://www.myownserver.com/index.php/c=SignIn&?token=302870637602746094276097

So the problem is that you can't have two question marks in the URL; the second needs to be an ampersand (&) to string more values together. The error message is a predictable Disallowed Key Characters.

Can anyone thing of a good/clever way to get around this issue I'm having? I really don't want to dump the CodeIgniter part of this setup because it has a great DB abstraction and good helpers that I've already written a good bit of code on.

Thanks for any suggestions.

+1  A: 

Hm. Can you do something clever with mod_rewrite and the QSA flag to automatically string it together, perhaps? I.e. have a rewrite for your 'root url' instead of tacking the ampersand onto it in facebook?

Amber
Dav is correct, the easiest way would be to rewrite the url BEFORE it gets processed by the url parser of codeigniter (in fact with mod_rewrite you should be able to rewrite both the url and the query string)
Sergi
A: 

Perhaps I don't fully understand your problem, but can't you add & to $config['permitted_uri_chars'] in the application/config/config.php file?

Johnny Tops
Alex Mcp
A: 

You can extend the Input Library to allow query strings and pretty urls.

Check out haughin.com for the Twitter Library, and see how he did it.

Zack
A: 

hello,

there is a twitter codeigniter library on http://newdailyblog.blogspot.com/2010/07/download-tweetsigniter.html. Thanks.

Tahsin Hasan