Slim3 parameter issues

$app->get('/mobile/byCategory/{id}{offset}{random}', function ($request, $response, $args) 
{  
    $categoryId = $args['id'];
    $page = $args['offset'];
    $random = $args['random'];
 }

I am sending request using Retrofit 2 from mobile device like this successfully:
…/mobile/byCategory/4610
Where
46 is category id
1 is offset
0 is random

But when i reach at offset 10 like
…/mobile/byCategory/46100
now slim3 retrieves parameters as
461 category id (but i send 46)
0 offset (but i send 10)
random is also 0

Please tell me the proper way to receive parameters. I will be very thankful.

It doesn’t look like you’ve given Slim any means to know which parameter is which. Is the category always two digits? Is the offset always one digit? Is the random always one digit?

Perhaps you could change the way the request is sent to something like this:

//  /mobile/byCategory/46/1/0
$app->get('/mobile/byCategory/{id}/{offset}/{random}', function ($request, $response, $args)

Or maybe use regex if the number of characters are known

//  /mobile/byCategory/4610
$app->get('/mobile/byCategory/{id:[0-9]{2}}', function ($request, $response, $args)
1 Like

Thank you. I have solved it by using query parameters in Get request.