您好,欢迎访问一九零五行业门户网

php接受xml和发送(post)xml_PHP教程

接收xml:
$xml = file_get_contents(php://input);
发送(post):
$xml_data = ...;
$url = http://dest_url;
$header[] = content-type: text/xml;//定义content-type为xml
curl_setopt($ch, curlopt_url, $url);
curl_setopt($ch, curlopt_returntransfer, 1);
curl_setopt($ch, curlopt_httpheader, $header);
curl_setopt($ch, curlopt_post, 1);
curl_setopt($ch, curlopt_postfields, $xml_data);
$response = curl_exec($ch);
if(curl_errno($ch))
{
    print curl_error($ch);
}
curl_close($ch); 
或者:
$fp = fsockopen($server, 80);
fputs($fp, post $path http/1.0);
fputs($fp, host: $server);
fputs($fp, content-type: text/xml);
fputs($fp, content-length: $contentlength);
fputs($fp, connection: close);
fputs($fp, ); // all headers sent
fputs($fp, $xml_data);
$result = ;
while (!feof($fp)) {
$result .= fgets($fp, 128);
}
return $result;
http://www.bkjia.com/phpjc/486462.htmlwww.bkjia.comtruehttp://www.bkjia.com/phpjc/486462.htmltecharticle接收xml: $xml = file_get_contents(php://input); 发送(post): $xml_data = xml.../xml ; $url = http://dest_url ; $header[] = content-type: text/xml;//定义content-type为xml curl...
其它类似信息

推荐信息