我正在尝试使用skyscanner api
http://business.skyscanner.net/portal/en-GB/Documentation/FlightsLivePricingDetails
获取预订详情部分
我正在尝试创建预订请求,以便我可以轮询它, 我试图放置的数据变量是正确的,但我只是返回服务器错误,所以我怀疑我的卷曲请求是有缺陷的
$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);
非常感谢任何帮助。
答案 0 :(得分:1)
使用PUT
请求时添加内容长度标题。
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Length: ' . strlen($dataVars)));