2014-03-02 61 views
2

我試圖使用Skyscanner上,API天空掃描儀API,創建預訂申請

http://business.skyscanner.net/portal/en-GB/Documentation/FlightsLivePricingDetails

獲取預訂信息部分

我試圖創建預訂這樣我就可以再申請輪詢它, 數據瓦爾我試圖把是正確的,但我只是得到返回的服務器errror所以我懷疑我的捲曲的要求是有缺陷的

$apiKey ='keygoeshere'; 
$Session = $_GET["session"]; 
$apiSessionUrl ='http://partners.api.skyscanner.net/apiservices/pricing/v1.0/'.$Session.'/booking'; 

$OutboundLegId = $_GET['OutboundLegId']; 
$InboundLegId = $_GET['InboundLegId']; 
$data = array('apiKey'=>$apiKey,'OutboundLegId' => $_GET['OutboundLegId'],'InboundLegId' => $InboundLegId); 
$dataVars = http_build_query($data); 

$ch = curl_init(); 

curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT"); 
curl_setopt($ch, CURLOPT_VERBOSE, 1); 
curl_setopt($ch, CURLOPT_HEADER, 1); 
curl_setopt($ch, CURLOPT_URL, $apiSessionUrl); 
curl_setopt($ch, CURLOPT_POSTFIELDS, $dataVars); 
$response = curl_exec($ch); 
curl_close($ch); 
var_dump($response); 

任何幫助非常感謝。

回答

1

添加內容長度標頭,因爲您使用PUT請求。

curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Length: ' . strlen($dataVars))); 
+0

感謝至少我現在正在與服務器通話 –