我正在尝试将 xml 发送到休息服务器。
$url = url;
$file = 'finn/test.xml';
$post = array('name' => 'fil','file_contents'=>'@'.$file);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: text/xml'));
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($ch);
当我运行此代码时,我得到一个空白响应。
我知道服务器或 xml 没有任何问题,因为当我使用它将文件上传到服务器时,一切正常。
<html>
<body>
<form name="bilupload" action="url" method="post" enctype="multipart/form-data">
partner: <input TYPE="FILE" NAME="fil" size="10">
<br>
<input type="submit" value="Send">
</form>
</body>
</html>
curl_getinfo 打印:
[url] => url
[content_type] => text/html;charset=ISO-8859-1
[http_code] => 200
[header_size] => 497
[request_size] => 144
[filetime] => -1
[ssl_verify_result] => 0
[redirect_count] => 0
[total_time] => 0.062231
[namelookup_time] => 2.7E-5
[connect_time] => 0.016873
[pretransfer_time] => 0.016928
[size_upload] => 3668
[size_download] => 35
[speed_download] => 562
[speed_upload] => 58941
[download_content_length] => 35
[upload_content_length] => 3668
[starttransfer_time] => 0.034394
[redirect_time] => 0
我已经为此苦苦挣扎了很长一段时间,如果有人能指出我正确的方向,我将不胜感激。