PHP code example of rubin / opensky

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

    

rubin / opensky example snippets


$openSkyApi = new \OpenSky\OpenSkyApi();

$openSkyApi->setCredentials('{username}', '{password}');

echo "ICAO\tLongitude\tLatitude\n";
foreach ($openSkyApi->getStatesAll(time: 1458564121, icao24: '3c6444')->getStates() as $state) {
    printf(
        "%s\t%f\t%f\n",
        $state->getIcao24(),
        $state->getLongitude(),
        $state->getLatitude()
    );
}

echo "ICAO\tLongitude\tLatitude\n";
foreach ($openSkyApi->getStatesAll(bBox: new \OpenSky\BoundingBox(45.8389, 47.8229, 5.9962, 10.5226))->getStates() as $state) {
    printf(
        "%s\t%f\t%f\n",
        $state->getIcao24(),
        $state->getLongitude(),
        $state->getLatitude()
    );
}

echo "ICAO\tLongitude\tLatitude\n";
foreach ($openSkyApi->getStatesAll(icao24: ['3c6444', '3e1bf9'])->getStates() as $state) {
    printf(
        "%s\t%f\t%f\n",
        $state->getIcao24(),
        $state->getLongitude(),
        $state->getLatitude()
    );
}

echo "ICAO\tDep  - Arr\n";
foreach ($openSkyApi->getFlightsAll(begin: 1517227200, end: 1517230800)->getFlights() as $flight) {
    printf(
        "%s\t%s - %s\n",
        $flight->getIcao24(),
        $flight->getEstDepartureAirport() ?: '----',
        $flight->getEstArrivalAirport() ?: '----'
    );
}

echo "ICAO\tDep  - Arr\n";
foreach ($openSkyApi->getFlightsAircraft(icao24: '3c675a', begin: 1517227200, end: 1517230800)->getFlights() as $flight) {
    printf(
        "%s\t%s - %s\n",
        $flight->getIcao24(),
        $flight->getEstDepartureAirport() ?: '----',
        $flight->getEstArrivalAirport() ?: '----'
    );
}

echo "ICAO\tDep  - Arr\n";
foreach ($openSkyApi->getFlightsArrival(airport: 'EDDF', begin: 1517227200, end: 1517230800)->getFlights() as $flight) {
    printf(
        "%s\t%s - %s\n",
        $flight->getIcao24(),
        $flight->getEstDepartureAirport() ?: '----',
        $flight->getEstArrivalAirport() ?: '----'
    );
}

echo "ICAO\tDep  - Arr\n";
foreach ($openSkyApi->getFlightsDeparture(airport: 'EDDF', begin: 1517227200, end: 1517230800)->getFlights() as $flight) {
    printf(
        "%s\t%s - %s\n",
        $flight->getIcao24(),
        $flight->getEstDepartureAirport() ?: '----',
        $flight->getEstArrivalAirport() ?: '----'
    );
}