繁体   English   中英

使用Soap或Rest Api在Php中连接Sabre API

[英]connect Sabre api in Php using Soap or Rest Api

我喜欢通过使用php文件dsbridge.php连接Flights API应用程序
ajax向curl桥类获取数组响应的请求

error - invalid_client
error_descr - Credentials are missing or the syntax is not correct.  

当我使用base64工具使用此过程制作_dsAppKey

  1. Base64您的客户编号
  2. Base64客户端机密
  3. 将两个Base64值连接在一起:
  4. Base64的串联。

它仍然给我响应代码为NULL。 此代码为我提供了访问令牌。

You have to send another request to the Sabre Api. 

请帮助我完成示例。

Use the following code for REST API access
<?php
ini_set('display_errors', 1);

$url='https://api.test.sabre.com/v1.9.0/shop/flights?mode=live';

$reffer="https://api.test.sabre.com";
$agent ="Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.3) Gecko/20070309 Firefox/2.0.0.3";


$data_string='{"OTA_AirLowFareSearchRQ":{"OriginDestinationInformation":[{"DepartureDateTime":"2016-01-05T00:00:00","DestinationLocation":{"LocationCode":"LAX"},"OriginLocation":{"LocationCode":"DFW"},"RPH":"1"},{"DepartureDateTime":"2016-01-07T00:00:00","DestinationLocation":{"LocationCode":"DFW"},"OriginLocation":{"LocationCode":"LAX"},"RPH":"2"}],"POS":{"Source":[{"RequestorID":{"CompanyName":{"Code":"TN"},"ID":"REQ.ID","Type":"0.AAA.X"}}]},"TPA_Extensions":{"IntelliSellTransaction":{"RequestType":{"Name":"200ITINS"}}},"TravelerInfoSummary":{"AirTravelerAvail":[{"PassengerTypeQuantity":[{"Code":"ADT","Quantity":1}]}]}}}';

$header[]='Authorization: your access token';
$header[]='Content-Type: application/json';
$header[]='Content-Length: ' . strlen($data_string);

$ch = curl_init(); 
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_USERAGENT, $agent);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_ENCODING,'gzip');
curl_setopt($ch, CURLOPT_REFERER, $reffer);
curl_setopt($ch, CURLOPT_HTTPHEADER,$header);
curl_setopt($ch, CURLOPT_POST,true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$content = curl_exec($ch);
echo "<pre>";
print_r(json_decode($content));

?>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM