PHP code example of lookyman / flightradar24

1. Go to this page and download the library: Download lookyman/flightradar24 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/ */

    

lookyman / flightradar24 example snippets


use GuzzleHttp\Client as GuzzleClient;
use GuzzleHttp\Psr7\HttpFactory;
use Lookyman\Flightradar24\Client;
use Lookyman\Flightradar24\Query\Boundary;
use Lookyman\Flightradar24\Query\FlightPositionsQuery;
use Lookyman\Flightradar24\Transport\Transport;

$client = new Client(new Transport($token, new GuzzleClient(), new HttpFactory()));

// Single object:
$airport = $client->airports->getFull('WAW');
echo $airport->name; // "Warsaw Chopin"

// List:
$positions = $client->livePositions->getLight(new FlightPositionsQuery(
    new Boundary(52.5, 52.0, 20.8, 21.3),
));
printf("Found %d aircraft.\n", count($positions));

use Lookyman\Flightradar24\Exception\ApiException;

try {
    $airport = $client->airports->getFull('ZZZ');
} catch (ApiException $e) {
    $status = $e->response->getStatusCode();
    $body = json_decode((string) $e->response->getBody(), true);
}