0

I'm using Codeigniter with the mvc, and I'm not using querystrings, but I have this api call to facebook, that returns a querystring.

Only thing is that when I get it back with site.com/controller/method?state=supm&code=supm I get a 310, because I'm not setup to handle querystrings. I can't change the config['uri_protocol'] to 'PATH_INFO', because then only my main page will get displayed, and none of the mvc parameteres will get interpreted (for some reason), so how can I make my page not fail, and still get the code and state from facebook?

Jakob
  • 4,784
  • 8
  • 53
  • 79

2 Answers2

1

Use $this->input->get() (see Input Class), just making sure you have allow_get_array set to TRUE in your config.php file.

I believe this item was added in CI 2.0 and is on by default, so it now allows you to access GET data without needing to use enable_query_strings.

Mike S.
  • 1,100
  • 1
  • 11
  • 22
0

Check out enabling query strings.

If you still like to preserve your old urls (site/controller/function/parameters), you'll have to insert a hook. This one looks fine (haven't tested it myself though).

Edit: Possible duplicate of this.

Community
  • 1
  • 1
Shomz
  • 37,421
  • 4
  • 57
  • 85
  • Thank you. Maybe it's a little drastic to change the entire pattern because I have a service that returns a querystring. i would rather do it the other way round. Preserve the uri segment pattern and then allow querystrings, or do you think that's not possible? – Jakob Nov 08 '11 at 15:46
  • You don't have to enable query strings to access the query values. I believe it was CI 2.0 where `$config['allow_get_array']` was introduced. – Mike S. Nov 08 '11 at 21:09
  • Jakob, yes, it's possible, either by the second example I gave you or regularly if you're using CI2, like Mike said @Mike You don't know if he's using CI2 or older, no reason to give a minus for that. – Shomz Nov 08 '11 at 23:37