如何在操作中检索$ _POST变量

时间:2012-09-06 17:33:18

标签: zend-framework post zend-http-client

我是zend框架中的新手, 我通过这种方式用post方法将一些数据发送到一个动作:

$config = array(
    'adapter'   => 'Zend_Http_Client_Adapter_Curl',
);

$client = new Zend_Http_Client('http://example.com/api/last-news', $config);
$client->setParameterPost('name' ,'value');
$dataresult = $client->request('POST')->getBody();

lastNewsAction()中的ApiController.php动作中我使用var_dump($_POST)时,它传递给我空数组,但是当我将这些数据发送到框架外的简单文件时(类似http://example.com/test.php } $_POST具有正确的值。那我怎样才能在动作中检索$_POST变量?

1 个答案:

答案 0 :(得分:2)

或者如果你想要它们......

if ($this->getRequest()->isPost()) {        
    $postData = $this->getRequest()->getPost();
    ...