请看以下代码:
<form id='myform' name='myform' action='http://www.xxx.xom' method='post' accept-charset='UTF-8'>
<input type='input' name='xmlData' value='<?xml version="1.0"?>
<order_zip>23222</order_zip>
<shipping_id>15</shipping_id>
<products><product> <product_id>230</product_id> <quantity>40</quantity></product></products>'>
</form>
当我发送表单数据时 - 我得到的响应是:好的。
但是我需要在后端(后台)进行。
所以我的代码是:
set xmlhttp = server.createobject("MSXML2.XMLHTTP")
xmlhttp.Open "POST",URL,False
xmlhttp.SetRequestHeader "Content-Type","text/xml;charset=UTF-8"
xmlhttp.Send xmlstring
Response.write(xmlhttp.response.text)
这次我收到错误响应:没有输入 XML 数据 技术人员只知道 php 没有 asp - 所以他不知道我需要在我的代码中更改什么。
这是php代码示例:
<?php
$xml['xmlData'] .= '<order_zip>187654</order_zip>';
$xml['xmlData'] .= '<shipping_id>3</shipping_id>';
$xml['xmlData'] .= '<products>';
$xml['xmlData'] .= '<product><product_id>458</product_id><quantity>11</quantity></product>';
$connection = curl_init();
curl_setopt($connection, CURLOPT_URL, "http://api.xml.com/xml/sendOrder");
curl_setopt($connection, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($connection, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($connection, CURLOPT_POST, 1);
curl_setopt($connection, CURLOPT_POSTFIELDS, $xml);
curl_setopt($connection, CURLOPT_RETURNTRANSFER, 1);
set_time_limit(108000);
$strResponse = curl_exec($connection);
if(curl_errno($connection)) {
print 'Curl error: ' . curl_error($connection);
}
curl_close($connection);
print_r($strResponse);
}
?>
我只需要表单在后台/后端运行 - 所以我很乐意获得正确的代码。
谢谢