0
我正在通過發送來自同一個盒子的curl POST請求來測試我在本地主機上運行的ZF2 Rest模塊。curl POST請求在ZF2 Rest API中爲空
curl -i -X POST -H "Content-Type: Application/json" -d '{username":"xyz","password":"xyz"}' http://localhost/api/login
在相應的控制器和動作,我試圖返回POST參數,但總是返回
var_dump($this->getRequest()); // returns: array(0){}
var_dump($_POST); // returns: array(0){}
空數組如果我從POST切換用於GET
curl -i -G -H "Content-Type: Application/json" -d '{username":"xyz","password":"xyz"}' http://localhost/api/login
它似乎工作
var_dump($_GET); // returns: array(1) {["{"username":"xyz","password":"xyz"}"]=>string(0) ""}
爲什麼POST請求無法傳遞/提取參數?
自己來到這個解決方案,但你是100%的權利。這是問題所在 – Pankrates 2014-09-24 23:10:49