POST xml to php with apache2

Posted by Berry on Stack Overflow See other posts from Stack Overflow or by Berry
Published on 2010-03-29T17:11:54Z Indexed on 2010/03/31 22:23 UTC
Read the original article Hit count: 306

Filed under:
|
|

I'm working on an application that receives XML data via POST, processes it with a PHP script, and returns an XML response.

I'm getting the XML with this PHP code:

$requestStr = file_get_contents('php://input');
$requests = simplexml_load_string($requestStr);

which works fine on the Linux-based product hardware using nginx as the server.

However, for testing I'd like to be able to run it on my MacBook Pro, so I can avoid the "build image, install on product, reboot product, wait, test change" loop while I do targeted development on this XML processor.

I enabled "web sharing" which starts up Apache, added a rewrite rule to point a convenient URI at my development source directory and used curl to send a request to my PHP script thus:

curl -H "Content-Type:text/xml" -d @request.xml http://localhost/test/path/testscript

"testscript" is handled by the PHP script fine, but when it goes to read "php:://input" I get nothing -- the empty string.

Anyone have a clue why this would work under Linux with nginx and not under MacOS with Apache?

I've googled and searched stackoverlow.com to no avail. Thanks for any answers.

UPDATE: I've discovered that at least in this configuration, reading from php://stdin will work fine, while php://input will not. Who knew?

© Stack Overflow or respective owner

Related posts about php

Related posts about Xml