嗯,這是我第一次去Zend,並且面臨着設置restful api的任務。我用了Zend其餘控制器,其代碼例如是這樣的: -使用Zend休息控制器與Zend休息客戶端
myzendrestcontroller-"localhost/alice/Theb2cController.php"
<?php
class Theb2cController extends Zend_Rest_Controller
{
public function init() {
$this->_helper->viewRenderer->setNoRender(true);
}
public function indexAction() {
$this->getResponse()
->appendBody($xml);
}
public function getAction() {
if ($this->getRequest()->getParam ("name") != NULL) {
$return =" wow";
} else {
$return= 'no parameters!';
}
echo $return
}
public function postAction() {
$salutation=$this->getRequest()->getParam("salutation");
}
public function putAction() {
}
public function deleteAction() {
$this->getResponse()
->appendBody("From deleteAction() deleting the requested article");
}
}
?>
客戶看起來是這樣的: -
myzendclient-"localhost/alice1/theb2cclient.php"
require_once("Zend/Rest/Client.php");
$url="localhost/alice/Theb2cController.php"
$client1=new Zend_Rest_Client($url);
$client1->name('alice');
$response=$client1->get();
echo $response;
但我沒有得到任何迴應,這只是一個空白屏幕。有人可以請幫忙
您是否將Zend的整個MVC框架或Zend_Rest類用作項目中的獨立對象? –
@Adrian我在運行restful web服務項目時只使用了zend rest classes – Rasmus