I am writing PHP code to send XML string data to a site using HTTP post with the encType: multipart/form-data encoding. I am thinking of using PHP's http_post_data function. Before sending the data, I believe I need to encode it, but I cannot see a PHP function to do this for me, nor do I know how to write such a function myself.
This is what I have so far (but http_request_body_encode() is certainly not the correct function):
$options = array('headers' => array('Content-Type' => 'multipart/form-data'));
$fields = array('operation' =>'doMDUpload', 'login_id' => $doi_username, 'login_passwd' => $doi_password,
'area' => ($debug ? "test" : "live"), 'fname' => $writer->outputMemory());
$info = array();
$response = http_post_data($crossref_deposit_url, http_request_body_encode($fields, array()), $options, $info);
$writer->outputMemory
is an XML string containing bibliometric data.