简体   繁体   English

苗条的框架,使用什么代替getParsedBody作为put方法?

[英]Slim framework, what to use instead of getParsedBody for put method?

I'm trying to build a rest API with the slim framework, however I have some trouble with the put request which doesn't allow GetParsedBody , I looked a lot on internet but didn't find usable method, the only one who worked is :parse_str($request->getBody()->getContents(), $icone); 我正在尝试使用苗条的框架构建一个rest API,但是我的put请求遇到了一些麻烦,该请求不允许GetParsedBody ,我在互联网上看了很多,但是找不到可用的方法,唯一起作用的是:parse_str($request->getBody()->getContents(), $icone); where icone is the variable to return. 其中icone是要返回的变量。

Here is my code if you want to see it but i don't matter for this question, thank you for your time ! 这是我的代码,如果您想看的话,但是我对这个问题并不重要,谢谢您的时间!

$app->put('/{id}', function($request, $response, $args) use ($app){

    $boucle = array();
    $route = $request->getAttribute('route');
    $courseId = $route->getArgument('id');

    parse_str($request->getBody()->getContents(), $icone);

    return $response->withJson($icone);
});

Try this 尝试这个

    $route=$req->getParsedBodyParam('route');
    $id=$req->getParsedBodyParam('id');

尝试这个:

parse_str($request->getBody()->__toString(), $icone);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM