CodeIgniter Forums
Problems with query string parameters - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Problems with query string parameters (/showthread.php?tid=44529)



Problems with query string parameters - El Forum - 08-17-2011

[eluser]joanfihu[/eluser]
I need to get the query string parameters from a url that twitter sends to me:

http://localhost:8888/marnews/index.php/dashboard/access_token?oauth_token=XXXXXXXXXXXXXXXX&oauth_verifier=XXXXXXXXXXXXXXXX

When I recive this request I get a 302 error and I'm redirected to: http://localhost:8888/marnews/index.php/dashboard/access_token (Notice that is the same url without query string parameters)

Do you know any way to get this parameters without enabling query strings?

I'm using Codeigniter Reactor 2.0.2

I've tried to do
Code:
echo $this->input->get('oauth_token');
and
Code:
print_r($_SERVER)
but I think that when I'm redirected and I loose this data.

Do you know how to fix this?

Thanks in advance.


Problems with query string parameters - El Forum - 08-17-2011

[eluser]regal2157[/eluser]
You should use post methods, if this is a form. If not, just make your URL something like
http://localhost:8888/marnews/index.php/dashboard/access_token/XXXXXXXXXXXXXXXX/XXXXXXXXXXXXXXXX

And then you can use the uri helper, and grab the segment(n) respective to each one.

E.G.
Code:
<?php
...
$token = $this->uri->segment(3);
$veri = $this->uri->segment(4);

If you want to use the GET method, you have to do some editing in other files to make it work. I would just stay away from it.


Problems with query string parameters - El Forum - 08-17-2011

[eluser]bretticus[/eluser]
Of course that is if you actually have the choice of specifying your URI with twitter. I still hate that CI squashes this. There are some work arounds. If you can do what @regal2157 suggests, go for it! If you can't, lemme know.


Problems with query string parameters - El Forum - 08-17-2011

[eluser]regal2157[/eluser]
Ha. Totally didn't even think about that. But for Twitter... http://codeigniter.com/wiki/OAuth_for_Twitter/


Problems with query string parameters - El Forum - 08-17-2011

[eluser]joanfihu[/eluser]
Hi,

I'm already using this library. I've fixed the problem. Seems that if you want to use query strings in CI 2.0.2 you have to change this lines in config.php:

Code:
$config['uri_protocol'] = 'QUERY_STRING';
$config['enable_query_strings'] = TRUE;

If you don't change it and use query strings you will be redirected (Error 302).

Thanks for all Smile