[Resolved, thanks] Query Strings in URL - 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: [Resolved, thanks] Query Strings in URL (/showthread.php?tid=17808) |
[Resolved, thanks] Query Strings in URL - El Forum - 04-16-2009 [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&min_date=1175756400&appkey=http://siteusingapi.com [Resolved, thanks] Query Strings in URL - El Forum - 04-16-2009 [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 } [Resolved, thanks] Query Strings in URL - El Forum - 04-16-2009 [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. [Resolved, thanks] Query Strings in URL - El Forum - 04-16-2009 [eluser]Fenix[/eluser] Nevermind, I tried it and got errors. http://mysite.com/api/categories?count=0&min_date=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 [Resolved, thanks] Query Strings in URL - El Forum - 04-16-2009 [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); [Resolved, thanks] Query Strings in URL - El Forum - 04-16-2009 [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 [Resolved, thanks] Query Strings in URL - El Forum - 04-20-2009 [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 Thanks. 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 |