//获取xml数据
$url = "http://localhost/baoxian/"; //body有xml数据的html
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, true); //表示需要response header
curl_setopt($ch, CURLOPT_NOBODY, false); //表示需要response body
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);//转字符串
$response = curl_exec($ch);
preg_match("/(<body>)(.*?)(<\/body>)/is", $response, $res); //获取html字符串里面的body里面的内容
$res[2]= preg_replace('/^( |\s)*|( |\s)*$/', '', $res[2]); //去掉前后的空格,不然无法读取
//dump($res[2]);die();
//模拟发送数据
$postUrl = 'http://localhost/baoxian/home/index/pay';
$ch = curl_init();//初始化curl
curl_setopt($ch, CURLOPT_URL,$postUrl);//抓取指定网页
curl_setopt($ch, CURLOPT_HEADER, 0);//设置header
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);//要求结果为字符串且输出到屏幕上
curl_setopt($ch, CURLOPT_POST, 1);//post提交方式
curl_setopt($ch, CURLOPT_POSTFIELDS, $res[2]);
$data = curl_exec($ch);//运行curl
//dump($data);
curl_close($ch); //关闭curl链接
$url = "http://localhost/baoxian/"; //body有xml数据的html
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, true); //表示需要response header
curl_setopt($ch, CURLOPT_NOBODY, false); //表示需要response body
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);//转字符串
$response = curl_exec($ch);
preg_match("/(<body>)(.*?)(<\/body>)/is", $response, $res); //获取html字符串里面的body里面的内容
$res[2]= preg_replace('/^( |\s)*|( |\s)*$/', '', $res[2]); //去掉前后的空格,不然无法读取
//dump($res[2]);die();
//模拟发送数据
$postUrl = 'http://localhost/baoxian/home/index/pay';
$ch = curl_init();//初始化curl
curl_setopt($ch, CURLOPT_URL,$postUrl);//抓取指定网页
curl_setopt($ch, CURLOPT_HEADER, 0);//设置header
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);//要求结果为字符串且输出到屏幕上
curl_setopt($ch, CURLOPT_POST, 1);//post提交方式
curl_setopt($ch, CURLOPT_POSTFIELDS, $res[2]);
$data = curl_exec($ch);//运行curl
//dump($data);
curl_close($ch); //关闭curl链接