2009-11-21 21 views
6

我想用Zend Framework編寫一個簡短的Rest服務。但是這部分文檔並不是最好的。帶Zend_Rest_Client的工作示例Zend_Rest_Controller?

我有一個ApiController擴展Zend_Rest_Controller與所有需要的抽象方法。我的目標是獲取發佈數據並返回一些內容。

我的客戶是這樣的:

public function indexAction() 
    { 
     $url = 'http://localhost/url/public/api'; 
     $client = new Zend_Rest_Client(); 
     $client->setUri($url); 
     $client->url = 'http://www.google.de'; 
     $result = $client->post(); 
    } 

,但所提供的「客戶端 - $> URL」是不是接線柱陣列服務器端裏面。我必須在我的ApiController的postAction中使用Zend Rest Server嗎?

如果有人舉例說明如何通過Zend Rest發送和獲取數據,那就太好了。

回答

0

您是否嘗試將其設置爲訪問127.0.0.1而不是本地主機?我知道這有時會導致問題。