当前位置:   article > 正文

携程机票接口写法_携程对外机票api数据接口

携程对外机票api数据接口

<?php

function httpRequestSoapData($responseUrl,$requestXML)
{
 try{
  $myhttp = new HttpRequest($responseUrl."?WSDL","POST");
  //--相对于API2.0固定
  $r_head=<<<BEGIN
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<Request xmlns="http://ctrip.com/">
<requestXML>
BEGIN;
  
  $r_end=<<<BEGIN
</requestXML>
</Request>
</soap:Body>
</soap:Envelope>
BEGIN;

  //返回头
  $responseHead=<<<begin
<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><RequestResponse xmlns="http://ctrip.com/"><RequestResult>
begin;
  //返回尾
  $responseEnd=<<<begin
</RequestResult></RequestResponse></soap:Body></soap:Envelope>
begin;


  $requestXML=str_replace("<",@"<",$requestXML);
  $requestXML=str_replace(">",@">",$requestXML);

  $requestXML=$r_head.$requestXML.$r_end;
  $myhttp->open();
  $myhttp->send($requestXML);
  $myhttp->getResponseBody();
  $coutw=$myhttp->getResponseBody();
  $coutw=str_replace($responseHead,"",$coutw);//替换返回头
  $coutw=str_replace($responseEnd,"",$coutw);//替换返回尾
  $coutw=str_replace("<","<",$coutw);//将符号换回来
  $coutw=str_replace(">",">",$coutw);//将符号换回来
   
  // echo $coutw;
  return $coutw;
 }
 catch (SoapFault $fault){
  return  $fault->faultcode;
 }
}

?>

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/IT小白/article/detail/874813
推荐阅读
相关标签
  

闽ICP备14008679号