[insert_PHP]
if (getenv(‘HTTP_CLIENT_IP’))
$ipaddress = getenv(‘HTTP_CLIENT_IP’);
else if(getenv(‘HTTP_X_FORWARDED_FOR’))
$ipaddress = getenv(‘HTTP_X_FORWARDED_FOR’);
else if(getenv(‘HTTP_X_FORWARDED’))
$ipaddress = getenv(‘HTTP_X_FORWARDED’);
else if(getenv(‘HTTP_FORWARDED_FOR’))
$ipaddress = getenv(‘HTTP_FORWARDED_FOR’);
else if(getenv(‘HTTP_FORWARDED’))
$ipaddress = getenv(‘HTTP_FORWARDED’);
else if(getenv(‘REMOTE_ADDR’))
$ipaddress = getenv(‘REMOTE_ADDR’);
else
$ipaddress = ‘UNKNOWN’;

$query = unserialize(file_get_contents(‘http://ip-api.com/php/’.$ipaddress));
if($query && $query[‘status’] == ‘success’) {

$country = $query[‘country’];
$city = $query[‘city’];
$lat = $query[‘lat’];
$long = $query[‘lon’];
$region = $query[‘region’];

} else {
$geoplugin = unserialize( file_get_contents(‘http://www.geoplugin.net/php.gp?ip=’ . $ipaddress) );

if ( is_numeric($geoplugin[‘geoplugin_latitude’]) && is_numeric($geoplugin[‘geoplugin_longitude’]) )
{ $lat = $geoplugin[‘geoplugin_latitude’];
$long = $geoplugin[‘geoplugin_longitude’];
$city = $geoplugin[‘geoplugin_city’];
$country = $geoplugin[‘geoplugin_countryName’];
$region = $geoplugin[‘geoplugin_regionName’];
}
}

$jsonurl = “https://api.sandbox.amadeus.com/v1.2/airports/nearest-relevant?apikey=LB98wK5iRjlR7ofWto1icfCJ5Ghqi2Xb&latitude=$lat&longitude=$long”;
$json = file_get_contents($jsonurl,0,null,null);
$json_output = json_decode($json);

$from_iata = $json_output[0]->airport;
$airport_name = $json_output[0]->airport_name;
$city_iata = $json_output[0]->city;
$city_name = $json_output[0]->city_name;
$distance = round($json_output[0]->distance, 2);

echo “Your Nearest Airport : $airport_name, $city_name
“;
echo “Your Estimated Distance From Airport: $distance KM
“;
$number_of_results = ‘4’;

$jsonurl1 = “https://api.sandbox.amadeus.com/v1.2/travel-intelligence/top-destinations?apikey=LB98wK5iRjlR7ofWto1icfCJ5Ghqi2Xb&period=2016-05&origin=$city_iata&number_of_results=4”;
$json1 = file_get_contents($jsonurl1,0,null,null);
$json_output1 = json_decode($json1);

$to = $json_output1->results->destination;
echo $to;

[/insert_PHP]