0

i created a route in slim api like this:

$app->put('/user/:one', function ($one) {

i know i created the put wrong by using it as a get, but i can't change the app since it's live. So I have to find a way to change this so it works when the json encoded variable contains a slash. When one of the fields in the json variable contain a slash the route thinks another variable is being declared. In this url the password contains a slash and thus breaks my route:

http://someapi.nl/someappApi/api.php/user/%7B%22uuid%22:%2267b80bda2ab6f83d%22,%22username%22:%22bladude%22,%22screen_state%22:%22Aan%20het%20werk%22,%22name%22:%22bladude%22,%22last_name%22:%22asdf%22,%22email%22:%22someexample@live.nl%22,%22password%22:%22bie/rtje/%22%7D

is there a way to tell slim api it should see the entire url as one variable??? or escape the slash?

Sjoerd de Wit
  • 2,353
  • 5
  • 26
  • 45

2 Answers2

0

You can use a wildcard route to capture the entire query string...

$app->put('/user/:one+', function ($one) {

geggleto
  • 2,605
  • 1
  • 15
  • 18
  • Yess, I had all ready solved but this was the way, it made the first var an array if there were multiple slash so I put a check on that and if it did I looped through values and pasted it together to a string :), thx anyway – Sjoerd de Wit Jan 21 '15 at 16:38
0

If you are using SLIM 3

$app->get('/hello[/{params:.*}]', function ($request, $response, $args) {
$params = explode('/', $request->getAttribute('params'));

// $params is an array of all the optional segments

});

I found this solution at "Slim 3 - Slash as a part of route parameter"

Sarim Shekhani
  • 128
  • 1
  • 5