PHP code example of therealartz / amadeus-php

1. Go to this page and download the library: Download therealartz/amadeus-php library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

therealartz / amadeus-php example snippets


use Amadeus\Client;

$apiKey = 'api_key';
$apiSecret = 'api_secret';

$client = new Client($apiKey, $apiSecret);

use Amadeus\Request\Shopping\FlightOffersRequestOptions;

$request = new FlightOffersRequestOptions(
    $origin = 'JFK',
    $destination = 'ORD',
    $departureDate = \DateTimeImmutable::createFromFormat('Y-m-d', '2020-03-01'), // Any \DateTimeInterface
    $returnDate = null,
    $adults = 2,
    $children = 0,
    $infants = 0,
    $seniors = 0,
    $travelClass = null,
    $nonStop = false,
    $currency = 'USD',
    $maxResults = 50,
    $maxPrice = null,
    $arrivalBy = null,
    $returnBy = null,
    $

use Amadeus\Client;
use Monolog\Logger;

$client = new Client(
    $apiKey = 'api_key',
    $apiSecret = 'api_secret',
    $isProduction = false,
    $logger = new Logger(
        'amadeus', 
        [
            new Monolog\Handler\StreamHandler(__DIR__ . '/var/log/amadeus.log')
        ]
    ),
);

use Amadeus\Client;
use Symfony\Component\Cache\Adapter\FilesystemAdapter;

$client = new Client(
    $apiKey = 'api_key',
    $apiSecret = 'api_secret',
    $isProduction = false,
    $logger = null,
    $cache = new FilesystemAdapter('amadeus', 0, __DIR__ . '/var/cache'),
);