<?php 
function GetPost_http($url, $data = '', $method = 'GET') {
	$curl = curl_init(); // 启动一个CURL会话  
	curl_setopt($curl, CURLOPT_URL, $url); // 要访问的地址  
	curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0); // 对认证证书来源的检查  
	curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0); // 从证书中检查SSL加密算法是否存在  
	curl_setopt($curl, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']); // 模拟用户使用的浏览器  
	curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1); // 使用自动跳转  
	curl_setopt($curl, CURLOPT_AUTOREFERER, 1); // 自动设置Referer  
	if ($method == 'POST' && !empty($data)) {
		curl_setopt($curl, CURLOPT_POST, 1); // 发送一个常规的Post请求  
		curl_setopt($curl, CURLOPT_POSTFIELDS, $data); // Post提交的数据包
		curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type:application/json'));
	}
	curl_setopt($curl, CURLOPT_TIMEOUT, 40); // 设置超时限制防止死循环  
	curl_setopt($curl, CURLOPT_TIMEOUT_MS, 40000); // 设置超时限制防止死循环  
	curl_setopt($curl, CURLOPT_HEADER, 0); // 显示返回的Header区域内容  
	curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); // 获取的信息以文件流的形式返回  
	$tmpInfo = curl_exec($curl); // 执行操作  
	$errno = curl_errno($curl);
	if ($errno !== 0) {
		log_message('error', 'ctripost'.$errno.curl_error($curl));
	}
	curl_close($curl); //关闭CURL会话  
	return $tmpInfo; //返回数据
}


$BackXml = file_get_contents('php://input');
/*$BackXml  = '';
$BackXml .= '<?xml version="1.0"?>';
$BackXml .= "<OrderProcessRequest xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>";
$BackXml .= '<Authentication>
      <ServiceName>web.order.requestRefund</ServiceName>
      <PartnerName>tieyou</PartnerName>
      <TimeStamp>2016-05-26 16:26:47</TimeStamp>
      <MessageIdentity>263A1E3FDCEBA0AEE61E49952E34C27D</MessageIdentity>
  </Authentication>
  <TrainOrderService>
      <OrderInfo>
          <OrderNumber>elonge20160526261753244</OrderNumber>
          <OrderTid>882c5548-b672-4484</OrderTid>
          <OrderTradeNo>882c5548-b672-4484</OrderTradeNo>
      </OrderInfo>
      <OrderTotleFee></OrderTotleFee>
      <TotalRefundAmount>5.50</TotalRefundAmount>
      <Reason>Test</Reason>
      <RefundType>T</RefundType>
  </TrainOrderService>
</OrderProcessRequest>';*/

$BackArr = simplexml_load_string($BackXml);
$ServiceName = $BackArr->Authentication->ServiceName;
if($ServiceName == 'web.order.returnTicketNotice'){
	$OrderNumber = $BackArr->TrainOrderService->OrderNumber;
}else{
	$OrderNumber = $BackArr->TrainOrderService->OrderInfo->OrderNumber;
}

$responsexml = '
<?xml version="1.0" encoding="utf-8"?>
	<OrderResponse>
	  <ServiceName>'.$ServiceName.'</ServiceName>
	  <OperationDateTime>'.date('Y-m-d H:i:s').'</OperationDateTime>  
	  <OrderNumber>'.$OrderNumber.'</OrderNumber>
	  <Status>SUCCESS</Status>
	  <ErrorResponse>
		<ErrorMessage>null</ErrorMessage>  
		<ErrorCode/>
	  </ErrorResponse>
	</OrderResponse>
';

echo $responsexml;

$BackJson = json_encode($BackArr);

$Url = 'http://www.mycht.cn/info.php/apps/trainsystem/callback/ctripcallback';

//发送数据
GetPost_http($Url,$BackJson,'POST');

?>