2011-01-06 10 views
1

m残りのAPIをzfで開発しています。 これは私のユーザコントローラです。残りのAPIアクション

From indexAction() returning all articles 

を取得し、このURL http://quickstart.local/user/メートルを実行していることで、私はポストをテストすることができますどのように

From getAction() returning the requested article 

を取得し、このURL http://quickstart.local/user/1メートルを実行して、

<?php 
class UserController extends Zend_Rest_Controller 
{ 

    public function init() 
    { 
     $this->_helper->viewRenderer->setNoRender(true); 
    } 

    public function indexAction() 
    { 
     $this->getResponse() 
      ->appendBody("From indexAction() returning all articles"); 
    } 

    public function getAction() 
    { 
     $this->getResponse() 
      ->appendBody("From getAction() returning the requested article"); 

    } 

    public function postAction() 
    { 
     $this->getResponse() 
      ->appendBody("From postAction() creating the requested article"); 

    } 

    public function putAction() 
    { 
     $this->getResponse() 
      ->appendBody("From putAction() updating the requested article"); 

    } 

    public function deleteAction() 
    { 
     $this->getResponse() 
      ->appendBody("From deleteAction() deleting the requested article"); 

    } 


} 
?> 

は、アクションを削除し、置きます。

おかげ

答えて

2

がZend_Rest_Controllerが自動的にルートます..あなたのコントローラのURLにCURLを経由して要求をPUTとDELETE、POSTを送信しようと、このパターン

http://quickstart.local/controller/action_name 

に従ってください適切な行動を求める

ありがとうございます!

+0

窓を使用しているので、他の方法があります – XMen

-1

HII

はSanil

+0

これをhttp://quickstart.local/user/delete/にすると、getactionとも呼ばれます。 – XMen

+0

urの名前を変更して他のアクションにアクションを取得してからもう一度試してください – lampdev

+1

HTTP POST、HTTP PUT、HTTP DELETEメソッドを実際に呼び出すことはできません。これはURLフォームの問題ではなく、HTTPリクエストの生成方法の問題です。 – Vika