[Resolved, thanks] Query Strings in URL |
[eluser]Fenix[/eluser]
Is there any way to use query strings for only part of a URL (and only for one controller)? I am making a REST API for a site and the following example would be ideal: Controller: api Method: categories Quote:http://mysite.com/api/categories?count=0...ingapi.com
[eluser]sharpe[/eluser]
try this function categories() { $this->config->set_item('uri_protocol','PATH_INFO'); parse_str($_SERVER['QUERY_STRING'],$_GET); print_r($_GET); //bla bla }
[eluser]Fenix[/eluser]
could you give an example of the output for that please? i don't have any code written yet and thought i better get this figured out before i begin.
[eluser]Fenix[/eluser]
Nevermind, I tried it and got errors. http://mysite.com/api/categories?count=0...1175756400 A PHP Error was encountered Severity: Notice Message: Use of undefined constant Ôuri_protocolÕ - assumed 'Ôuri_protocolÕ' Filename: controllers/api.php Line Number: 17 A PHP Error was encountered Severity: Notice Message: Use of undefined constant ÔPATH_INFOÕ - assumed 'ÔPATH_INFOÕ' Filename: controllers/api.php Line Number: 17 A PHP Error was encountered Severity: Notice Message: Use of undefined constant ÔQUERY_STRINGÕ - assumed 'ÔQUERY_STRINGÕ' Filename: controllers/api.php Line Number: 18 A PHP Error was encountered Severity: Notice Message: Undefined index: ÔQUERY_STRINGÕ Filename: controllers/api.php Line Number: 18
[eluser]pistolPete[/eluser]
You should not copy directly from above: The forum software converted the quotes because the code was not posted in [ code ] tags Code: parse_str($_SERVER['QUERY_STRING'],$_GET);
[eluser]Fenix[/eluser]
Ok thanks, I didn't even notice. It works without this line, which is fine because I'm not even sure what it does because it wasn't explained. Code: $this->config->set_item(‘uri_protocol’,‘PATH_INFO’); Thanks
[eluser]jabberjab[/eluser]
I've been trying to follow what has been written here but I am unable to use query strings on this example URL. Code: example.com/user/add?title=someTitle&url=http://someurl.com I have however been able to use query strings on Code: example.com/index.php?c=user&m=add&title=someTitle&url=http://someurl.com Anyone got a suggestion as to how to achieve the first type of URL? I am guessing I should probably route it somehow. It'd be great if someone could let me know or at least point me in the right direction ![]() Also: So that there's no misunderstanding. I'm using .htaccess to remove the need of index.php, which is why I'd definitely like the solution presented in the first URL ![]() |
Welcome Guest, Not a member yet? Register Sign In |