Using standard PHP Curl for VACENTRAL API Call

I would like to use the VACENTRAL Api call to get some information like Airport data to include in my related project.

However I do not want to mess with hosting and c-panel trying to both install Composer and VACENTRAL and woth rather call the API using Curl and pass the appropriate keys as I Have done this before on other API calls.

 

My question is has anyone or Nabeel got some documentation or an example PHP script to call the api in CUFRL and parse the returned data.

 

 

I have worked it out by looking at the code of the VACENTRAL Module  without installing it with Composer

 

the code is as follows -:   YOU MUST USE A VAILD API KEY and not the ‘ZZZZZZZZZZZZZZZ’

 

<?php

/**

* Class and Function List:

* Function list:

* Classes list:

*/

/** \file      vacentral.php

*  \brief     Text  getting data from Vacentral using Curl

*  \details   This Script is used tinstead of Composer installation

*  \author    Leslie Jarrett

*  \version   1.0

*  \date      2025

*  \copyright 2025 Leslie Jarrett

*/

//

// GET AIRPORT INFORMATION FROM VACENTRAL

//

// The following URl string is required to get Airport Information

//

// https://api.vacentral.net/api/airports/[ICAO]?apiKey=[API_KEY]

//

// Where you replace [ICAO] with the Airport code you want to get data forr

//

// and replace [API_KEY] with your user API Key string

//

// Below is a worked example for the airport EGEW

// Using my own API KEY which is then hidden from the code

//

// set up your API KEY

//

$ApiKey = ‘zzzzzzzzzzzzzzzzzzzzzzzzzzz’;

//

// set up the Airport ICAO code

//

$AirportIcao = ‘EGEW’;

//

// set up the first part of the CURL URl

//

$AirportApiUrl = ‘https://api.vacentral.net/api/airports/’;

//

// add in the Airport Icao Code

//

$AirportApiUrl = $AirportApiUrl.$AirportIcao;

//

// add in the API Key

//

$AirportApiUrl = $AirportApiUrl.‘?apiKey=’.$ApiKey;

//

// now process the call to the API using Curl

//

// set the api curl handle

//

$AirportApiHandle = curl_init();

//

// Will return the response, if false it prints the response

//

curl_setopt($AirportApiHandle, CURLOPT_RETURNTRANSFER, true);

//

// Set the url

//

curl_setopt($AirportApiHandle, CURLOPT_URL,$AirportApiUrl);

//

// Execute the session and store the contents in $AirporApiRaw

//

$AirporApiRaw =curl_exec($AirportApiHandle,);

//

// Closing the session

//

curl_close($AirportApiHandle);

//

// upack the Json data to PHP array

//

$AirportData = json_decode($AirporApiRaw, true);

//

// the array $AirportData wwill have the following fields

//

// array(10) {

// [“icao”]=>

// string(4) “EGEW”

// [“iata”]=>

// string(3) “WRY”

// [“name”]=>

// string(15) “Westray Airport”

// [“city”]=>

// string(7) “Westray”

// [“country”]=>

// string(2) “GB”

// [“region”]=>

// string(6) “GB-SCT”

// [“tz”]=>

// string(13) “Europe/London”

// [“elevation”]=>

// int(29)

// [“lat”]=>

// float(59.3502998352)

// [“lon”]=>

// float(-2.9500000477)

// }

 

?>

Do you really need an API Key or authorization for this ? Below is a plain query result without an API key.

 

{ "icao": "EGEW", "iata": "WRY", "name": "Westray Airport", "city": "Westray", "country": "GB", "region": "GB-SCT", "tz": "Europe/London", "elevation": 29, "lat": 59.3502998352, "lon": -2.9500000477 }

 

And it will be better if you just use the “code” feature of the forum with “php” language selected. Your cleaned up, more readable code will look like this if you do so.

 

\<?php /\*\* \* Class and Function List: \* Function list: \* Classes list: \*/ /\*\* \file vacentral.php \* \brief Text getting data from Vacentral using Curl \* \details This Script is used tinstead of Composer installation \* \author Leslie Jarrett \* \version 1.0 \* \date 2025 \* \copyright 2025 Leslie Jarrett \*/ // // GET AIRPORT INFORMATION FROM VACENTRAL // // The following URl string is required to get Airport Information // https://api.vacentral.net/api/airports/[ICAO]?apiKey=[API\_KEY] // Where you replace [ICAO] with the Airport code you want to get data forr // and replace [API\_KEY] with your user API Key string // Below is a worked example for the airport EGEW // Using my own API KEY which is then hidden from the code // set up your API KEY $ApiKey = 'zzzzzzzzzzzzzzzzzzzzzzzzzzz'; // set up the Airport ICAO code $AirportIcao = 'EGEW'; // set up the first part of the CURL URl $AirportApiUrl = 'https://api.vacentral.net/api/airports/'; // add in the Airport Icao Code $AirportApiUrl = $AirportApiUrl.$AirportIcao; // add in the API Key $AirportApiUrl = $AirportApiUrl.'?apiKey='.$ApiKey; // now process the call to the API using Curl // set the api curl handle $AirportApiHandle = curl\_init(); // Will return the response, if false it prints the response curl\_setopt($AirportApiHandle, CURLOPT\_RETURNTRANSFER, true); // Set the url curl\_setopt($AirportApiHandle, CURLOPT\_URL,$AirportApiUrl); // Execute the session and store the contents in $AirporApiRaw $AirporApiRaw =curl\_exec($AirportApiHandle,); // Closing the session curl\_close($AirportApiHandle); // unpack the Json data to PHP array $AirportData = json\_decode($AirporApiRaw, true); // the array $AirportData will have the following fields // array(10) { // ["icao"] =\> string(4) "EGEW" // ["iata"] =\> string(3) "WRY" // ["name"] =\> string(15) "Westray Airport" // ["city"] =\> string(7) "Westray" // ["country"] =\> string(2) "GB" // ["region"] =\> string(6) "GB-SCT" // ["tz"] =\> string(13) "Europe/London" // ["elevation"] =\> int(29) // ["lat"]=\> float(59.3502998352) // ["lon"]=\> float(-2.9500000477) // } ?\>

 

Have a nice day.

Vacentral returned an error for airport  AYTU. the returned ICAO should have read AYTU

 

array(10) {

  [“icao”]=>

  string(6) “PG-TFI”

  [“iata”]=>

  string(3) “TFI”

  [“name”]=>

  string(12) “Tufi Airport”

  [“city”]=>

  string(4) “Tufi”

  [“country”]=>

  string(2) “PG”

  [“region”]=>

  string(6) “PG-NPP”

  [“tz”]=>

  string(0) “”

  [“elevation”]=>

  int(85)

  [“lat”]=>

  float(-9.07595443726)

  [“lon”]=>

  float(149.319839478)

}

Also the a similar error for ICAO BGAK      ? should the values be corrected  but since I call  VACENTRAL API with  iCAO BGAK anyway then I do not  need the contents of that field in theory 

array(10) {

  [“icao”]=>

  string(6) “GL-QCU”

  [“iata”]=>

  string(3) “QCU”

  [“name”]=>

  string(17) “Akunnaaq Heliport”

  [“city”]=>

  string(8) “Akunnaaq”

  [“country”]=>

  string(2) “GL”

  [“region”]=>

  string(5) “GL-QK”

  [“tz”]=>

  string(0) “”

  [“elevation”]=>

  int(59)

  [“lat”]=>

  float(68.744273)

  [“lon”]=>

  float(-52.340369)

}

another one for icao DNBA

 

array(10) {

  [“icao”]=>

  string(6) “NG-BCU”

  [“iata”]=>

  string(0) “”

  [“name”]=>

  string(14) “Bauchi Airport”

  [“city”]=>

  string(6) “Bauchi”

  [“country”]=>

  string(2) “NG”

  [“region”]=>

  string(5) “NG-BA”

  [“tz”]=>

  string(0) “”

  [“elevation”]=>

  int(1998)

  [“lat”]=>

  float(10.294402)

  [“lon”]=>

  float(9.816672)

}

and for DNSU

array(10) {

  [“icao”]=>

  string(6) “NG-QRW”

  [“iata”]=>

  string(3) “QRW”

  [“name”]=>

  string(13) “Warri Airport”

  [“city”]=>

  string(5) “Warri”

  [“country”]=>

  string(2) “NG”

  [“region”]=>

  string(5) “NG-DE”

  [“tz”]=>

  string(0) “”

  [“elevation”]=>

  int(242)

  [“lat”]=>

  float(5.59611)

  [“lon”]=>

  float(5.81778)

}

and this for DNGO

 

array(10) {

  [“icao”]=>

  string(7) “NG-0003”

  [“iata”]=>

  string(3) “GMO”

  [“name”]=>

  string(35) “Gombe Lawanti International Airport”

  [“city”]=>

  string(5) “Gombe”

  [“country”]=>

  string(2) “NG”

  [“region”]=>

  string(5) “NG-GO”

  [“tz”]=>

  string(0) “”

  [“elevation”]=>

  int(1590)

  [“lat”]=>

  float(10.298889)

  [“lon”]=>

  float(10.9)

}

The issue is likely in the source data vacentral uses for airport lookup.

15 hours ago, ProAvia said:

The issue is likely in the source data vacentral uses for airport lookup.

I have posted the errors I found on trying 3402 airports

4 minutes ago, LesJar said:

I have posted the errors I found on trying 3402 airports

 

They should be reported at GitHub probably (if there is an open repository for it), any reports will be lost in a blink of an eye here at forum.

25 minutes ago, DisposableHero said:

 

They should be reported at GitHub probably (if there is an open repository for it), any reports will be lost in a blink of an eye here at forum.

 

That is a good idea as well as then I can probably post the log files there as well

 

1 Like

Check this github repository for the airports in question

https://github.com/mwgg/Airports

You can open an issue there for needed corrections.

 

Also check https://ourairports.com/

 

The vaCentral DB gets updated from time to time.

Last I knew, the above data sources were used - but this may have changed.

 

 

5 minutes ago, ProAvia said:

Check this github repository for the airports in question

https://github.com/mwgg/Airports

You can open an issue there for needed corrections.

 

Also check https://ourairports.com/

 

The vaCentral DB gets updated from time to time.

Last I knew, the above data sources were used - but this may have changed.

 

 

Will check that out but of course Vacentrsl needs the database updated 

1 hour ago, LesJar said:

Will check that out but of course Vacentrsl needs the database updated 

It gets updated from time to time. 
But if the source DB isn’t updated, neither will vaCentral - even if a vaCentral update is done. 
 

13 hours ago, ProAvia said:

It gets updated from time to time. 
But if the source DB isn’t updated, neither will vaCentral - even if a vaCentral update is done. 
 

 

That is the main problem.

 

Unfortunately both sources vaCentral uses are free and unofficial / public databases. Most of the time they can contain wrong data, saved by contributors, or they can come up with some sort of quick solutions themselves (like automated ICAO codes as TR-00085 etc.)

 

I posted my concerns about the sources before but so far no solid solution was found, we will have problems from time to time. (Worst part, they do affect vmsAcars operations too, not limited to phpVMS)

55 minutes ago, DisposableHero said:

 

That is the main problem.

 

Unfortunately both sources vaCentral uses are free and unofficial / public databases. Most of the time they can contain wrong data, saved by contributors, or they can come up with some sort of quick solutions themselves (like automated ICAO codes as TR-00085 etc.)

 

I posted my concerns about the sources before but so far no solid solution was found, we will have problems from time to time. (Worst part, they do affect vmsAcars operations too, not limited to phpVMS)

I am a member of OURAirports and will try and get the data updated where possible as the long term benefit to all concerned and not just Flight simulation Community is that the data has more data for use and corrections made where possible

 

I have done similar for GeoNames Airport data 

 

1 Like