<?php
/*$auth_data = array(
'client_id' => 'z8r6KvgvPRGSwzHWQCdMGL2Z4CEk7HG7',
'client_secret' => 'wcIX72i08MwboHN1',
'grant_type' => 'client_credentials'
);*/
error_reporting(0);
require_once 'vendor/rmccue/requests/library/Requests.php';
Requests::register_autoloader();
$url = 'https://test.api.amadeus.com/v1/security/oauth2/token';
$auth_data = array(
'client_id' => 'fXzAFuAn3jjcLzuz5UZbo0pJhq1ZJKpA',
'client_secret' => 'or05SCg3KszdyPIJ',
'grant_type' => 'client_credentials'
);
$headers = array('Content-Type' => 'application/x-www-form-urlencoded');

$requests_response = Requests::post($url, $headers, $auth_data);
$response_body = json_decode($requests_response->body, true);
echo '<pre>';
$token = $response_body['access_token'];
$access_token = $token;

$curl = curl_init();
$tkn = "$access_token";
curl_setopt_array($curl, array(
  CURLOPT_URL => "https://test.api.amadeus.com/v2/shopping/flight-offers?originLocationCode=BOM&destinationLocationCode=DEL&departureDate=2025-01-25&adults=2&children=0&infants=0&travelClass=ECONOMY&nonStop=false&currencyCode=USD&max=1",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'GET',
  CURLOPT_HTTPHEADER => array(
    "Authorization: Bearer $tkn"
  ),
));

$response = curl_exec($curl);
curl_close($curl);
$result = json_decode($response, true);
print_r($result);
?>