Posting XML with curl (command line) without using key / value pairs

Consider a PHP script that outputs all data POST

like this:

<?php var_dump($_POST); ?>

      

The script is in http://example.com/foo.php

.

Now I want to send XML data to it (without using key / value pairs) using the command line curl

. I've tried many options:

curl -H "Content-type: text/xml; charset=utf-8" --data-urlencode "<foo><bar>bazinga</foo></bar>" http://example.com/foo.php

      

However, none of them seem to post anything - according to the PHP script, $_POST

is just an empty array.

What am I doing wrong here?

+2


a source to share


1 answer


(Disclaimer: My acquaintance with PHP goes back and forth.)

I believe that $ _POST only works if PHP can parse the input as regular key / value pairs. You need to access the original POST data directly. This can be helpful:



http://www.codediesel.com/php/reading-raw-post-data-in-php/

+2


a source







All Articles