Welcome Guest, Not a member yet? Register   Sign In
Route URL with GET parameters to cleaner URL
#1

[eluser]vendiddy[/eluser]
Hi, I am trying to figure out how to reroute a url like application/test?token=123 to a url like application/test/123. This is because the Zend_Gdata library needs to send an authentication token back to a method of my controller in the form of a GET parameter.

Code:
function test_gcal_auth()
{
    $this->load->library('zend');
    $this->zend->load('Zend/Gdata/Calendar');
    $this->zend->load('Zend/Gdata/AuthSub');        
    $scope = 'http://www.google.com/calendar/feeds/';
    $secure = true;
    $session = true;
    $next = $this->config->item('base_url') . 'system/umdcal/test.php';
    $url = Zend_Gdata_AuthSub::getAuthSubTokenUri($next, $scope, $secure, $session);
    echo sprintf('<a href="%s">Login</a>', $url);
}

I currently use a hack where I set the next url to be test.php. In test.php, I extract the GET parameter and redirect to the correct method in my application controller. (As seen below.)

Code:
$token = $_GET['token'];
header("Location: http://localhost/umdcal.php/application/test/$token");

Does anyone know of a cleaner solution? I tried adding a regex pattern in routes.php but wasn't able to get it working.

Thanks!


Messages In This Thread
Route URL with GET parameters to cleaner URL - by El Forum - 10-01-2008, 11:42 PM
Route URL with GET parameters to cleaner URL - by El Forum - 10-02-2008, 05:53 AM
Route URL with GET parameters to cleaner URL - by El Forum - 10-02-2008, 10:58 AM
Route URL with GET parameters to cleaner URL - by El Forum - 10-02-2008, 02:35 PM
Route URL with GET parameters to cleaner URL - by El Forum - 10-02-2008, 02:40 PM
Route URL with GET parameters to cleaner URL - by El Forum - 11-01-2008, 02:18 AM



Theme © iAndrew 2016 - Forum software by © MyBB