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.
The following appears in the logcat when the application is sending the data:
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:
$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:
The parameters bag uses a different format for deeper items.. try using $lat = $this->getRequest()->get('location[lat]', null, true).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.