dertin
April 8, 2019, 6:32pm
1
Hi, how can I do to route the following URL?
URL: https://example.com/User/1s3ddfg2?username=1234&password=1234
$app->get(’User/{token:/(.+)[?]}’, ‘User:login’);
This is correct?
And how do I get the values of the token and the GET parameters in my controller?
ajay
April 8, 2019, 6:36pm
2
public function something($request, $response){
$username = $request->getParam('username');
extract token with args ‘user/token/???’
1 Like
dertin
April 8, 2019, 7:00pm
3
{
"message": "Slim Application Error",
"exception": [
{
"type": "FastRoute\\BadRouteException",
"code": 0,
"message": "Regex \"/(.+)[?]\" for parameter \"token\" contains a capturing group",
"file": "/var/www/example.com/htdocs/vendor/nikic/fast-route/src/DataGenerator/RegexBasedAbstract.php",
"line": 145,
dertin
April 8, 2019, 7:09pm
4
/User/AAAAA?username=user@mail.com&password=23456
$app->get(’User/{token}’, ‘User:login’);
$arrInputParams = $objRequest->getParams();
["username"]=>
string(13) "user@mail.com"
["password"]=>
string(5) "23456"
How to get the token value? (AAAAA)
Antnee
April 8, 2019, 7:57pm
5
Doing this from my phone, so forgive the brevity.
Your controller action method should take three parameters; request, response and arguments array. You’ll find the value that you’re looking for in the array
1 Like
dertin
April 8, 2019, 8:00pm
6
Thanks, I was getting complicated with the regular expression and it was not necessary. It’s solved.
1 Like