2

I'm trying to use the skyscanner api

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

get booking details section

I'm trying to create the request for booking so I can then poll it, The data vars I am trying to put are correct, but I just get returned a server errror so I suspect my curl request is flawed

$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);

Any Help much appreciated.

4

1 回答 1

1

在使用PUT请求时添加内容长度标头。

curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Length: ' . strlen($dataVars))); 
于 2014-03-02T17:37:30.013 回答