Posting XML via curl (command-line) without using key/value pairs
- by Mathias Bynens
Consider a PHP script that outputs all POST data, as follows:
<?php var_dump($_POST); ?>
The script is located at http://example.com/foo.php.
Now, I want to post XML data to it (without using key/value pairs) using command line curl. I have tried many variations of the following:
curl -H "Content-type: text/xml; charset=utf-8" --data-urlencode "<foo><bar>bazinga</foo></bar>" http://example.com/foo.php
Yet none of them seem to actually post anything — according to the PHP script, $_POST is just an empty array.
What am I doing wrong here?