0

我有一个非常奇怪的问题。我正在尝试使用 Skyscanner API 从 JSON GET 请求返回一个数组。

我在 cURL 中生成和使用的 Skyscanner URL 是:http ://partners.api.skyscanner.net/apiservices/browseroutes/v1.0/DE/EUR/de-DE/HAM/PT/2016-12?apiKey =API_KEY

它返回 3 个引号,但是当我使用像http://www.jsoneditoronline.org/这样的 JSON 编辑器时,它给了我 9 个引号!!!

为什么它在我的解决方案中显示较少的引号?我如何获得所有报价???

<?php

$cities = array("HAM");
$countries = array("PT");
$url_api = "http://partners.api.skyscanner.net/apiservices/browseroutes/v1.0/DE/EUR/de-DE/";
$api_key = "API_KEY_HERE";

$next_month = date('m')+1;
if ($next_month=="13") {
    $this_year = date('Y')+1;
    $next_month = "01";
} else {
    $this_year = date('Y');
}

foreach($cities as $city){

    foreach($countries as $country){
    $url = $url_api.$city."/".$country."/".$this_year."-".$next_month."?apiKey=".$api_key;
    $ip = "218.255.245.210";
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_HEADER, false);
    curl_setopt($ch, CURLOPT_POST, false);
    curl_setopt($ch, CURLOPT_ENCODING, 'gzip');
    curl_setopt($ch, CURLOPT_VERBOSE, 1);
    curl_setopt($ch, CURLOPT_HTTPHEADER, array('Accept: application/json', 'X_FORWARDED_FOR: '.$ip));
    curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4 );
    $data = curl_exec($ch);
    $response = json_decode($data);
    echo $url."<br/>";
    $quotes = $response->Quotes;
    foreach($quotes as $quote){
        echo $quote->QuoteId.". ";
        echo $quote->Direct."<br/>";
        }
    }
}

?>
4

0 回答 0