CodeIgniter: Use GET Parameters for OAuth or Facebook

Codeignitor destroys your GET parameters, because it does not use it, however for applications that use OAuth, Facebook Applications or Facebook authentication using Facebook connect, GET parameters are required.

In order to retrieve GET parameters from Code Ignitor, first we have to change the config.php, uri_protocol to PATH_INFO, this solves 404 Errors with GET parameters on Codeigniter

/* |-------------------------------------------------------------------------- | URI PROTOCOL |-------------------------------------------------------------------------- | | This item determines which server global should be used to retrieve the | URI string. The default setting of "AUTO" works for most servers. | If your links do not seem to work, try one of the other delicious flavors: | | 'AUTO' Default - auto detects | 'PATH_INFO' Uses the PATH_INFO | 'QUERY_STRING' Uses the QUERY_STRING | 'REQUEST_URI' Uses the REQUEST_URI | 'ORIG_PATH_INFO' Uses the ORIG_PATH_INFO | */ $config['uri_protocol'] = "PATH_INFO"; Now in your model or controller you can rebuild the GET parameters using the $_SERVER['QUERY_STRING'] variable. parse_str($_SERVER['QUERY_STRING'],$_GET);

Now $_GET parameter should be rebuild with GET parameters.

:) 02 Apr, 2010
Comments (1)
  • CodeIgniter Get Parameters OAuth

    Thanks, very helpful!

    By Stan on 28 May, 2010
You may also like
Tags
On Facebook
Email Newsletter