code

<?php

// token from oAuth call
$BEARER_TOKEN = "token from oAuth call";

// Host in the URL
$host = "https://api.lufthansa.com/";

// Settings for your App: Language of your App
$lang = "de";

// Parameters
$lat = "51.5";
$long = "-0.142";

$context = stream_context_create ( array (
		'http' => array (
				'header' => array (
						'Accept: application/xml',
						'Authorization:Bearer ' . $BEARER_TOKEN 
				) 
		) 
) );

$url = $host . 'v1/references/airports/nearest/' . $lat . ',' . $long . '?lang=' . $lang;

try {
	$response_plain = file_get_contents ( $url, false, $context );
	$response = new SimpleXMLElement ( $response_plain );
} catch ( Exception $e ) {
	var_dump ( $e->getMessage () );
}

?>
<div class="container">

	<h1>Nearest Airports</h1>

	<p>&nbsp;</p>

	<p>The nearest Airports for the position <?= $lat ?>,<?= $long ?> are:</p>

	<div class="table-responsive">
		<table class="table table-striped">
			<thead>
				<tr>
					<th>Airport-Code</th>
					<th>Position</th>
					<th>Airport-Name</th>
					<th>Distance</th>
					<th>City Code</th>
					<th>Country Code</th>
					<th>LocationType</th>
				</tr>
			</thead>
			<tbody>

				<?php
				foreach ( $response->Airports [0]->Airport as $airport ) {
					?>

					<tr>
					<td><?= $airport->AirportCode ?></td>
					<td><?= $airport->Position->Coordinate->Latitude ?>,<?= $airport->Position->Coordinate->Longitude ?></td>
					<td><?= $airport->Names->Name?></td>
					<td><?= $airport->Distance->Value ?> <?= $airport->Distance->UOM ?></td>
					<td><?= $airport->CityCode ?></td>
					<td><?= $airport->CountryCode ?></td>
					<td><?= $airport->LocationType ?></td>
				</tr>

				<?php
				}
				?>
			</tbody>
		</table>
	</div>

	<pre class="pre-scrollable">
		<?= htmlentities($response_plain)?>
	</pre>

</div>

Offers Operations Reference Data oAuth