dcsimg
www.webdeveloper.com
Results 1 to 6 of 6

Thread: REST Webservice: PUT & Delete methods

  1. #1
    Join Date
    Sep 2006
    Posts
    688

    Question REST Webservice: PUT & Delete methods

    Hi All

    I am using Guzzle PHP client to make REST calls for PUT and DELETE.

    On the server I have this code in my index.php file where the request is being made.

    PHP Code:
    //index.php
    echo $_SERVER['REQUEST_METHOD'], '<BR>';
    print_r($_REQUEST);
    print_r(getallheaders()) 
    For GET and POST methods, I am getting the values of all three variable/functions ie. $_SERVER['REQUEST_METHOD'], $_REQUEST and getallheaders(), but in case of PUT and DELETE methods I am only getting value of $_SERVER['REQUEST_METHOD'] i.e PUT or DELETE and just the data in the getallheaders(), but nothing in the $_REQUEST variable.

    What could be the reason?

    Any inputs will be great...


    Thanks

  2. #2
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    21,299
    I believe what you want is:
    PHP Code:
    $inputData file_get_contents("php://input"); 
    "Well done....Consciousness to sarcasm in five seconds!" ~ Terry Pratchett, Night Watch

    How to Ask Questions the Smart Way (not affiliated with this site, but well worth reading)

    My Blog
    cwrBlog: simple, no-database PHP blogging framework

  3. #3
    Join Date
    Sep 2006
    Posts
    688
    Hi NogDog

    Thanks, yes its working fine...

    BTW, what does php://input do??

  4. #4
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    21,299
    It's one of several PHP "I/O streams" (or "wrappers").
    "Well done....Consciousness to sarcasm in five seconds!" ~ Terry Pratchett, Night Watch

    How to Ask Questions the Smart Way (not affiliated with this site, but well worth reading)

    My Blog
    cwrBlog: simple, no-database PHP blogging framework

  5. #5
    Join Date
    Sep 2006
    Posts
    688
    Hi again

    What about getting data from HEAD method? How do we do that?

    Both file_get_contents("php://input") and $_REQUEST does not seem to output anything

    Thanks

  6. #6
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    21,299
    I don't know for sure what it means with regard to any data submission when you specify HEAD as the method, but normally it's only used for things like validating links and testing connections -- but I'm not sure why you'd want/need to use it for a REST request?
    "Well done....Consciousness to sarcasm in five seconds!" ~ Terry Pratchett, Night Watch

    How to Ask Questions the Smart Way (not affiliated with this site, but well worth reading)

    My Blog
    cwrBlog: simple, no-database PHP blogging framework

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles