I'm making an API with PHP Slim 2.
I'm trying to get a JSON of the request which have an obligatory dqaid and optional parameters.
$app->get('/stats/getCrash/dqaid=:dqaid(/appid=:app_id(/reason=:reason(/appvid=:app_version_id(/reasonh=:reason_hash
(/brand=:brand(/model=:model(/osversion=:os_version(/portal=:portal))))))))',
function ($dqaid, $app_id = null, $reason = null, $app_version_id = null, $reason_hash = null, $brand = null,
$model = null, $os_version = null, $portal = null) use ($app) {
$app->response->setStatus(200);
$app->response->setBody(json_encode(CrashFilters::createRequest($dqaid, $app_id, $reason, $app_version_id, $reason_hash, $brand,
$model, $os_version, $portal)));
$app->response->headers->set('Content-Type', 'application/json');
});
this works if I put the optional parameters in the right order like this :
localhost:8180/stats/getCrash/dqaid=ff50640713c84a99/appid=229338/reason=150258106
But if I omit one or put them in the wrong order I get an error 404.
I'd like to be able to put only those I want and in the order I want.
Another question : I'd like to be able to access my page like that in the future :
localhost:8180/stats/getCrash?dqaid=ff50640713c84a99&appid=229338&reason=150258106
So using ? and & instead of / in my url.
Where can I set that ?