轮询Skyscanner航班实时价格时出错代码410

时间:2017-01-19 09:54:31

标签: php api curl skyscanner

我正在使用Skyscanner API查询实时价格。虽然我收到了session_key,虽然我立即轮询结果,但我得到一个410(Gone)响应标题,其中包含空体。它曾经在我的localhost环境中正常工作,但不再在我的实时服务器上工作。

以前有没有人经历过这个问题,可以给我一个提示可能是什么问题?

$url_api = "http://partners.api.skyscanner.net/apiservices/pricing/v1.0/";
$api_key = "XXX"; // Not shown here
$data = array('apiKey' => $api_key, 'country' => 'DE', 'currency' => 'EUR',
'locale' => 'de-DE', 'originplace' => 'HAM', 'destinationplace' => 'AMS', 'cabinclass' => 'economy', 'outbounddate' => '2017-01-27', 
'inbounddate' => '2017-01-30' , 'locationschema' => 'Iata', 'groupPricing' => true);


$httpdata = http_build_query($data);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url_api);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $httpdata);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded', 'Accept: application/json'));
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_ENCODING, 'gzip');
curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4 );

$response = curl_exec($ch);
curl_close($ch);

$headers = get_headers_from_curl_response($response);

$url = $headers['Location']."?apiKey=".$api_key."&stops=0";

echo $url;
return;

0 个答案:

没有答案