我已经发送了JSON
使用 android java 的数据,通过在 post 实体中设置它,如下所示:
HttpPost httpPostRequest = new HttpPost(URLs.AddRecipe);
StringEntity se = new StringEntity(jsonObject.toString());
httpPostRequest.setEntity(se);
我怎样才能收到这个json
数据在php
,我正在使用的地方Slim framework
?
我已经尝试过这个:
$app->post('/recipe/insert/', 'authenticate', function() use ($app) {
$response = array();
$json = $app->request()->post();
});
JSON 没有被解析成$_POST
超全球。在$_POST
您可以找到表单数据。您可以在请求正文中找到 JSON。像下面这样的东西应该有效。
$app->post("/recipe/insert/", "authenticate", function() use ($app) {
$json = $app->request->getBody();
var_dump(json_decode($json, true));
});
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)