Welcome Guest, Not a member yet? Register   Sign In
How to use Phil Sturgeon's REST_SERVER
#3

[eluser]PaulDunn[/eluser]
Im just testing with the example code from the posted tutorial.

When I access the resource from the browser with http://localhost/user/id/1 I get the expected output.

When using curl from the osx terminal I get a 404 error. Im trying with:
curl http://localhost/user/id/1

From what i've read that should be all I need for a simple GET request using curl.

Also I dont know how to POST to this example api. By that I mean how can I test the post function with say xml or json. I cannot seem to get this working with curl.

Code:
require(APPPATH'.libraries/REST_Controller.php');  
  
class Example_api extends REST_Controller {  
  
    function user_get()  
    {  
        $data = array('returned: '. $this->get('id'));  
        $this->response($data);  
    }  
  
    function user_post()  
    {  
        $data = array('returned: '. $this->post('id'));  
        $this->response($data);  
    }  
  
    function user_put()  
    {  
        $data = array('returned: '. $this->put('id'));  
        $this->response($data;  
    }  
  
    function user_delete()  
    {  
        $data = array('returned: '. $this->delete('id'));  
        $this->response($data);  
    }  
}


Messages In This Thread
How to use Phil Sturgeon's REST_SERVER - by El Forum - 11-18-2010, 09:21 AM
How to use Phil Sturgeon's REST_SERVER - by El Forum - 11-18-2010, 09:59 AM
How to use Phil Sturgeon's REST_SERVER - by El Forum - 11-18-2010, 10:07 AM
How to use Phil Sturgeon's REST_SERVER - by El Forum - 11-18-2010, 10:14 AM
How to use Phil Sturgeon's REST_SERVER - by El Forum - 11-18-2010, 10:17 AM
How to use Phil Sturgeon's REST_SERVER - by El Forum - 11-18-2010, 10:22 AM
How to use Phil Sturgeon's REST_SERVER - by El Forum - 11-21-2010, 07:37 AM
How to use Phil Sturgeon's REST_SERVER - by El Forum - 11-21-2010, 09:01 AM
How to use Phil Sturgeon's REST_SERVER - by El Forum - 11-21-2010, 09:31 AM
How to use Phil Sturgeon's REST_SERVER - by El Forum - 11-21-2010, 10:52 AM
How to use Phil Sturgeon's REST_SERVER - by El Forum - 11-21-2010, 12:34 PM
How to use Phil Sturgeon's REST_SERVER - by El Forum - 11-21-2010, 02:23 PM
How to use Phil Sturgeon's REST_SERVER - by El Forum - 11-22-2010, 02:50 AM
How to use Phil Sturgeon's REST_SERVER - by El Forum - 11-22-2010, 02:59 AM
How to use Phil Sturgeon's REST_SERVER - by El Forum - 12-04-2010, 04:54 PM
How to use Phil Sturgeon's REST_SERVER - by El Forum - 12-09-2010, 02:38 AM
How to use Phil Sturgeon's REST_SERVER - by El Forum - 12-09-2010, 04:08 AM
How to use Phil Sturgeon's REST_SERVER - by El Forum - 03-16-2011, 11:14 AM
How to use Phil Sturgeon's REST_SERVER - by El Forum - 03-16-2011, 11:18 AM
How to use Phil Sturgeon's REST_SERVER - by El Forum - 03-16-2011, 11:22 AM



Theme © iAndrew 2016 - Forum software by © MyBB