CLI CURL -> PHP CURL
Try this:
$ch = curl_init(); curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'Content-Type: application/atom+xml' ));curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);curl_setopt($ch, CURLOPT_URL, 'http://siteurl.com');curl_setopt($ch, CURLOPT_POST, 1);curl_setopt($ch, CURLOPT_POSTFIELDS, file_get_contents($filename)); curl_exec($ch);
The correct thing would be to read the file into a string and then provide that string to the CURLOPT_POSTFIELDS options. That feature of reading into a string is not provided by libcurl but is done by the command line client and I don't think the PHP/CURL binding offers the equivalent.
The command line uses --data-binary which corresponds to a CURLOPT_POSTSFIELDS with a string, not a hash array as the array will turn the post in to a multipart post (which the command line does with -F, --form). Also, the custom request set to POST is totally superfluous.
Usually, running the command line with "--libcurl test.c" is a good way to get a first draft version of a C program using the C API, but as the PHP API is very similar that should work as decent start in most cases.
Edit: and custom changing/providing the "Content-Length:" header is never a good idea unless you know perfectly well what you're doing. libcurl will always provide one that is generated based on the data you pass on to it.