通过cURL发送XML的功能

Here's my function which should send XML to the server specified in the config, and then convert the response (which is XML) to an array..

public function xmlResponse($data) {
    // sends the request to Atheme's XMLRPC interface via cURL
    $request = curl_init();
    curl_setopt($request, CURLOPT_URL, $this->atheme_host);
    curl_setopt($request, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($request, CURLOPT_TIMEOUT, 6);
    curl_setopt($request, CURLOPT_POSTFIELDS, $data);
    curl_setopt($request, CURLINFO_HEADER_OUT, true);
    curl_setopt($request, CURLOPT_HTTPHEADER, array('Connection: close', 'Content-Type: text/xml'));
    $response = curl_exec($request);
    curl_close($request);

    // converts recieved XML into a PHP array and returns
    return json_decode(json_encode((array) simplexml_load_string($response)), 1);
}

However, this returns False when I do a var_dump. I'm not sure what the problem is and have been diagnosing it for a while now. Would be grateful if someone could point out the problem and a solution. It's something wrong with cURL I believe.

Thanks!

Not being familiar with Atheme or its API, I'm not sure if this will help or not, but some APIs that accept XML work like this:

$header = "Connection: close
";
$header .= "Content-Type: text/xml

";
$header .= $data;

$request = curl_init();
curl_setopt($request, CURLOPT_URL, $this->atheme_host);
curl_setopt($request, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($request, CURLOPT_TIMEOUT, 6);
curl_setopt($request, CURLOPT_HEADER, false);
curl_setopt($request, CURLOPT_CUSTOMREQUEST, $header);
$response = curl_exec($request);
curl_close($request);