作爲項目的一部分,我試圖爲開放源碼的Android應用程序創建Web門戶,但是我在解析來自應用程序的一些數據時遇到了一些麻煩。從應用程序中獲取變量POST
在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");
但是,這似乎並沒有正確地抓住變量。任何人都可以看到我要去哪裏嗎?
'$ this-> getRequest() - > get(「location」);'返回一個關鍵數組,關鍵字爲'lat'等 – stevenll
參數bag使用不同的格式來表示更深的項目。 '$ lat = $ this-> getRequest() - > get('location [lat]',null,true)'。有關更多信息,請查看http://symfony.com/doc/current/components/http_foundation/introduction.html#accessing-request-data中的第二個代碼塊。 – qooplmao
工作過!謝謝! –