简体   繁体   English

从应用程序POST抓取变量

[英]Grabbing Variables from Application POST

As part of a project I'm trying to make web portal for a open source Android application however I am having some trouble parsing some of the data coming from the application. 作为项目的一部分,我试图为开放源代码的Android应用程序创建Web门户,但是在解析来自该应用程序的某些数据时遇到了一些麻烦。

The following appears in the logcat when the application is sending the data: 当应用程序发送数据时,logcat中将显示以下内容:

Sending using 'POST' - URI: http://WEBSITE/api/v2/devices/133/data.json - parameters: {location[lat]=55.8275143, location[accuracy]=10.0, location[lng]=-1.6821027}

I'm just confused as to how I grab this data, at the moment I'm trying to use the following in Symfony with Doctrine: 我只是对如何获取这些数据感到困惑,此刻我正试图在Symfony和Doctrine中使用以下内容:

$lat = $this->getRequest()->get("location:lat");
$lng = $this->getRequest()->get("location:lng");
$acc = $this->getRequest()->get("location:accuracy");

But this doesn't seem to grab the variables correctly. 但这似乎不能正确地获取变量。 Can anyone see where I am going wrong? 谁能看到我要去哪里错了?

 public function parseActionRequest(Request $request){
        $receivedRawData = $request->getContent() ;
        $parsedData = json_decode($receivedRawData, true);
...
}

Using what was suggested by Qoop in the comments solved this issue: 使用Qoop在评论中建议的内容解决了此问题:

The parameters bag uses a different format for deeper items.. try using $lat = $this->getRequest()->get('location[lat]', null, true). 参数包对较深的项目使用不同的格式。.尝试使用$ lat = $ this-> getRequest()-> get('location [lat]',null,true)。

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

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