XML解析错误:未找到任何元素

时间:2014-11-04 16:55:33

标签: php xml post curl call

我很新,所以我可能会遗漏一些明显的东西,

我正在进行像这样的卷曲POST调用:

$import = '<client><fullname>Space Ada</fullname></client>';

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://www.examplesecure.com/clients.xml");

curl_setopt($ch, CURLOPT_USERPWD, "12343223434fkgnfd:x");
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
//curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_SSLVERSION, 3);//fixes http_code 400

curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
//curl_setopt($ch, CURLOPT_POST , true);



//curl_setopt($ch, CURLOPT_VERBOSE ,1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

curl_setopt($ch, CURLOPT_HTTPHEADER, array('Accept: application/xml','Content-Length: ' . strlen($import)));
curl_setopt($ch, CURLOPT_POSTFIELDS,$import);

$data = curl_exec($ch);
$info = curl_getinfo($ch);
curl_close($ch);
if ($info['http_code'] == 400) {
    echo "RESPONSE:" . $data;
    echo "<br/>INFOS:";
    echo "<pre>";
    var_export($info);
} else {
    header("Content-type: text/xml");
    echo $data;}

浏览器(firefox)回答: XML解析错误:未找到任何元素 地点:http://localsite.dev/test-post.php 第2行,第1列:

我尝试过不同的POSTFIELDS格式,但无法找到解决方案, 欢迎任何想法_

0 个答案:

没有答案