来自Zend_Amf_Server的空响应

时间:2012-06-24 19:02:16

标签: php amf zend-amf

当我从flash调用端点时,所有操作都完成但响应为空。代码是:

class AmfController extends Zend_Controller_Action {
    public function indexAction()
    {
        $server = new Zend_Amf_Server();
        $server->setProduction(false);
        $server->setClass('Application_Model_Amf');
        $response = $server->handle();
        echo $response;
    }
}

class Application_Model_Amf {
    /**
     *
     * @param bytearray $data
     * @param string $dateString
     * @return int
     */
    public function save($data, $dateString)
    {
        $dateString = str_replace(array('|', ':'), array('_', ''), $dateString);
        //file_put_contents("$dateString.jpg", $data);
        $r = new stdClass();
        $r->error = 0;
        return $r;
    }
}

我也试过

    public function save($data, $dateString)
    {
        $dateString = str_replace(array('|', ':'), array('_', ''), $dateString);
        //file_put_contents("$dateString.jpg", $data);
        return true;
    }

但它既没有效果 - 仍然是空洞的回应。我怎么能像这个stdClass()一样返回响应?或者只有整数值1或0?

1 个答案:

答案 0 :(得分:0)

解决方案是添加die()

public function indexAction()
{
    $server = new Zend_Amf_Server();
    $server->setProduction(false);
    $server->setClass('Application_Model_Amf');
    $response = $server->handle();
    echo $response;
    die();
}