从应用程序POST中获取变量


Grabbing Variables from Application POST

作为项目的一部分,我正在尝试为开源Android应用程序创建门户网站,但在解析来自该应用程序的一些数据时遇到了一些问题。

当应用程序发送数据时,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}

我只是对如何获取这些数据感到困惑,目前我正试图在Symfony with Doctrine中使用以下内容:

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

但这似乎没有正确地抓住变量。有人看到我哪里出错了吗?

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

使用Qoop在评论中的建议解决了这个问题:

参数包对更深层次的项目使用不同的格式。。尝试使用$lat=$this->getRequest()->get('location[lat]',null,true)。