首页 > 代码库 > php使用curl提交xml数据

php使用curl提交xml数据

$str_callback_url="xxxx.com/api.php";
$str_callback_url="xml数据";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $str_callback_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 5);
curl_setopt($ch, CURLOPT_POST, 1);
$arr_header[] = "Content-type: text/xml";
curl_setopt($ch, CURLOPT_HTTPHEADER, $arr_header);
curl_setopt($ch, CURLOPT_POSTFIELDS, $str_xml);
$str_return_data = http://www.mamicode.com/curl_exec($ch);