我正在尝试开始使用amadeus sandbox travel api,并且刚刚开始使用api docs

  <?php
require_once(__DIR__ . '/vendor/autoload.php');

$api_instance = new Swagger\Client\Api\DefaultApi();
$apikey = "jJtGVQ********************RONJZq1"; // string | API Key provided for your account, to identify you for API access. Make sure to keep this API key secret.
$origin = "NYC"; // string | <a href=\"https://en.wikipedia.org/wiki/International_Air_Transport_Association_airport_code\">IATA code</a> of the city from which the traveler will depart. See the location and airport interfaces for more information.
$destination = "LAX"; // string | <a href=\"https://en.wikipedia.org/wiki/International_Air_Transport_Association_airport_code\">IATA code</a> of the city to which the traveler is going
$departure_date = "2017-12-16--2017-12-26"; // string | Range of dates between which the traveler could depart. Dates are specified in the <a href=\"https://en.wikipedia.org/wiki/ISO_8601\">ISO 8601</a> yyyy-MM-dd date format. Ranges are inclusive and ranges of months will apply from the start to the end of the month. If just a single date is specified, only that date will be searched. By default, the date range starts today and applies up to 361 in the future is applied. Past dates are generally not supported, future dates should be in the next 361 days, although results start to become sparse after about 6 months in the future, as airlines may still be defining their schedules. The default is to search all future dates available.
$one_way = false; // bool | When set to true, the query will be for a single trip from the origin to the destination. When this parameter is not provided, or is set to false, the query is for a round trip from the origin to the destination and back again.
$duration = "1--15"; // string | The allowed duration or range of durations of the trip, in days. This parameter must not be set if the one-way parameter is set to true.
$direct = false; // bool | Limit the search to results that do not require the passenger to change plane?
$max_price = "100000"; // string | Maximum price of trips to find in the result set, in the currency specified for this origin and destination pair in the cache contents spreadsheet. So, for example, if the origin is NYC, and the max price is 400, this means 400 USD. If the origin is PAR, and the max price is 400, this means 400 EUR. By default, no limit is applied
$aggregation_mode = ""; // string | Specifies the granularity of results to be found. DESTINATION is the default and finds one result per city. COUNTRY finds one result per country, DAY finds on result for every day in the date range, WEEK finds one result for every week in the date range. Note that specifying a small granularity but a large search scope may result in a huge output. For some very large outputs, the API may refuse to provide a result.

try {
    $result = $api_instance->flightInspirationSearch($apikey, $origin, $destination, $departure_date, $one_way, $duration, $direct, $max_price, $aggregation_mode);
    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling DefaultApi->flightInspirationSearch: ', $e->getMessage(), PHP_EOL;
}
?>

这是我用来执行搜索的示例代码
但这给我一个错误

调用DefaultApi时发生异常



如果有人能告诉我为什么会出现此错误,我将不胜感激,我实际上是使用xampp在php> 7.0的Windows机器上进行本地测试

我认为这是因为我缺少依赖关系,但需要帮助
谢谢

.php_cs
│   .travis.yml
│   autoload.php
│   composer.json
│   composer.lock
│   git_push.sh
│   index.php
│   phpunit.xml.dist
│   README.md
│   tree
│   tree.txt
│
├───docs
│   ├───Api
│   │       DefaultApi.md
│   │
│   └───Model
│
│
├───lib
│   │
│   │
│   ├───Api
│   │       │   │
│   └───Model
│
├───test
│   ├───Api
│   │   │
│   └───Model
│
│
└───vendor

最佳答案

检查NYC是否代表有效的机场代码(在我看来,不是)。

09-25 17:45