PHP XML Request Travelport API



我试图通过XML/SOAPTravelports uAPI获得响应,但我没有得到任何有用的东西。 print_rvar_dumpecho都只是Resource id #2展示了哪个东西,但无法进一步。

我已经尝试了他们的 API 测试工具来发送 XML 请求,它工作正常,但无法让它在 PHP 中工作。我以前解析过XML,但从不发送请求。

法典:

<?php
$CREDENTIALS = '******************';
$message = '
<?xml version="1.0" encoding="utf-16"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<s:Body>
 <air:AvailabilitySearchReq TraceId="P107788" AuthorizedBy="User" TargetBranch="P107788" xmlns:air="http://www.travelport.com/schema/air_v23_0" xmlns:com="http://www.travelport.com/schema/common_v20_0">
  <com:BillingPointOfSaleInfo OriginApplication="UAPI" /> 
 <air:SearchAirLeg>
 <air:SearchOrigin>
  <com:Airport Code="SYD" /> 
  </air:SearchOrigin>
 <air:SearchDestination>
  <com:Airport Code="MEL" /> 
  </air:SearchDestination>
  <air:SearchDepTime PreferredTime="2013-12-30" /> 
  </air:SearchAirLeg>
 <air:SearchAirLeg>
 <air:SearchOrigin>
  <com:Airport Code="MEL" /> 
  </air:SearchOrigin>
 <air:SearchDestination>
  <com:Airport Code="SYD" /> 
  </air:SearchDestination>
  <air:SearchDepTime PreferredTime="2014-01-02" /> 
  </air:SearchAirLeg>
 <air:AirSearchModifiers>
 <air:PreferredProviders>
  <com:Provider Code="1P" />
  </air:PreferredProviders>
 <air:PreferredCarriers>
  <com:Carrier Code="QF" /> 
  </air:PreferredCarriers>
  </air:AirSearchModifiers>
  <com:SearchPassenger Code="ADT" /> 
  <com:SearchPassenger Code="ADT" /> 
  </air:AvailabilitySearchReq>
  </s:Body>
  </s:Envelope>
';
$auth = $CREDENTIALS; //should base_64_encode() this!
$soap_do = curl_init("https://americas-uapi.copy-webservices.travelport.com/B2BGateway/connect/uAPI/Service"); 
$header = array( 
"Content-Type: text/xml;charset=UTF-8",
"Accept: gzip,deflate",
"Cache-Control: no-cache",
"Pragma: no-cache",
"SOAPAction: """, 
"Authorization: Basic $auth",
"Content-length: ".strlen($message),
); 
curl_setopt($soap_do, CURLOPT_CONNECTTIMEOUT, 60); 
curl_setopt($soap_do, CURLOPT_TIMEOUT, 60); 
curl_setopt($soap_do, CURLOPT_SSL_VERIFYPEER, false); 
curl_setopt($soap_do, CURLOPT_SSL_VERIFYHOST, false); 
curl_setopt($soap_do, CURLOPT_POST, true );
curl_setopt($soap_do, CURLOPT_POSTFIELDS, $message);
curl_setopt($soap_do, CURLOPT_HTTPHEADER, $header);
curl_setopt($soap_do, CURLOPT_RETURNTRANSFER, true);
curl_exec($soap_do);

print_r($soap_do); echo '<br>';
var_dump($soap_do);
echo '<br>'.$soap_do;
?>

任何帮助只是让我开始都会很棒。 :)

我是Travelport的合作伙伴技术专家,我理解您的沮丧。 我们之前对端点的用法和描述一直令人困惑。如果您登录我们的开发人员门户,则会更新 PHP 示例;https://developer.travelport.com/app/developer-network/resource-centre-uapi

最简单的方法是"取消全选",然后专门选择"示例代码"。

试一试!

只需更改

$soap_do = curl_init("https://americas-uapi.copy-webservices.travelport.com/B2BGateway/connect/uAPI/Service");

$soap_do = curl_init("https://americas-uapi.copy-webservices.travelport.com/B2BGateway/connect/uAPI/AirService");

相关内容

  • 没有找到相关文章

最新更新