# Using standard PHP Curl for VACENTRAL API Call

**URL:** <https://forum.phpvms.net/t/using-standard-php-curl-for-vacentral-api-call/14125>\
**Category:** Help and Support\
**Created:** [May 31, 2025, 5:09pm UTC](https://forum.phpvms.net/t/using-standard-php-curl-for-vacentral-api-call/14125 "2025-05-31T17:09:39Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![LesJar](https://forum.phpvms.net/letter_avatar_proxy/v4/letter/l/ad7895/32.png) [@LesJar](https://forum.phpvms.net/u/LesJar)\
**Post date:** [May 31, 2025, 5:09pm UTC](https://forum.phpvms.net/t/using-standard-php-curl-for-vacentral-api-call/14125/1 "2025-05-31T17:09:39Z")

</div>

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.

&nbsp;

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.

&nbsp;

&nbsp;

---

<div class="post-metadata">

**Author:** ![LesJar](https://forum.phpvms.net/letter_avatar_proxy/v4/letter/l/ad7895/32.png) [@LesJar](https://forum.phpvms.net/u/LesJar)\
**Post date:** [June 1, 2025, 7:20am UTC](https://forum.phpvms.net/t/using-standard-php-curl-for-vacentral-api-call/14125/2 "2025-06-01T07:20:38Z")

</div>

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

&nbsp;

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

&nbsp;

\<?php

/\*\*

\* Class and Function List:

\* Function list:

\* Classes list:

\*/

/\*\* \file&nbsp; &nbsp; &nbsp; vacentral.php

\*&nbsp; \brief &nbsp; &nbsp; Text&nbsp; getting data from Vacentral using Curl

\*&nbsp; \details &nbsp; This Script is used tinstead of Composer installation

\*&nbsp; \author&nbsp; &nbsp; Leslie Jarrett

\*&nbsp; \version &nbsp; 1.0

\*&nbsp; \date&nbsp; &nbsp; &nbsp; 2025

\*&nbsp; \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]](https://api.vacentral.net/api/airports/%5BICAO%5D?apiKey=%5BAPI_KEY%5D)

//

// 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/](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)

// }

&nbsp;

?\>

---

<div class="post-metadata">

**Author:** ![DisposableHero](https://forum.phpvms.net/user_avatar/forum.phpvms.net/disposablehero/32/1457_2.png) [@DisposableHero](https://forum.phpvms.net/u/DisposableHero)\
**Post date:** [June 1, 2025, 11:28am UTC](https://forum.phpvms.net/t/using-standard-php-curl-for-vacentral-api-call/14125/3 "2025-06-01T11:28:59Z")

</div>

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

&nbsp;

```
{ "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 }

```

&nbsp;

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.

&nbsp;

```
\<?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) // } ?\>

```

&nbsp;

Have a nice day.

---

<div class="post-metadata">

**Author:** ![LesJar](https://forum.phpvms.net/letter_avatar_proxy/v4/letter/l/ad7895/32.png) [@LesJar](https://forum.phpvms.net/u/LesJar)\
**Post date:** [June 2, 2025, 2:24pm UTC](https://forum.phpvms.net/t/using-standard-php-curl-for-vacentral-api-call/14125/4 "2025-06-02T14:24:26Z")

</div>

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

&nbsp;

array(10) {

&nbsp; [“icao”]=\>

&nbsp; string(6) “PG-TFI”

&nbsp; [“iata”]=\>

&nbsp; string(3) “TFI”

&nbsp; [“name”]=\>

&nbsp; string(12) “Tufi Airport”

&nbsp; [“city”]=\>

&nbsp; string(4) “Tufi”

&nbsp; [“country”]=\>

&nbsp; string(2) “PG”

&nbsp; [“region”]=\>

&nbsp; string(6) “PG-NPP”

&nbsp; [“tz”]=\>

&nbsp; string(0) “”

&nbsp; [“elevation”]=\>

&nbsp; int(85)

&nbsp; [“lat”]=\>

&nbsp; float(-9.07595443726)

&nbsp; [“lon”]=\>

&nbsp; float(149.319839478)

}

---

<div class="post-metadata">

**Author:** ![LesJar](https://forum.phpvms.net/letter_avatar_proxy/v4/letter/l/ad7895/32.png) [@LesJar](https://forum.phpvms.net/u/LesJar)\
**Post date:** [June 2, 2025, 2:28pm UTC](https://forum.phpvms.net/t/using-standard-php-curl-for-vacentral-api-call/14125/5 "2025-06-02T14:28:48Z")

</div>

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

array(10) {

&nbsp; [“icao”]=\>

&nbsp; string(6) “GL-QCU”

&nbsp; [“iata”]=\>

&nbsp; string(3) “QCU”

&nbsp; [“name”]=\>

&nbsp; string(17) “Akunnaaq Heliport”

&nbsp; [“city”]=\>

&nbsp; string(8) “Akunnaaq”

&nbsp; [“country”]=\>

&nbsp; string(2) “GL”

&nbsp; [“region”]=\>

&nbsp; string(5) “GL-QK”

&nbsp; [“tz”]=\>

&nbsp; string(0) “”

&nbsp; [“elevation”]=\>

&nbsp; int(59)

&nbsp; [“lat”]=\>

&nbsp; float(68.744273)

&nbsp; [“lon”]=\>

&nbsp; float(-52.340369)

}

---

<div class="post-metadata">

**Author:** ![LesJar](https://forum.phpvms.net/letter_avatar_proxy/v4/letter/l/ad7895/32.png) [@LesJar](https://forum.phpvms.net/u/LesJar)\
**Post date:** [June 2, 2025, 2:34pm UTC](https://forum.phpvms.net/t/using-standard-php-curl-for-vacentral-api-call/14125/6 "2025-06-02T14:34:36Z")

</div>

another one for icao&nbsp;DNBA

&nbsp;

array(10) {

&nbsp; [“icao”]=\>

&nbsp; string(6) “NG-BCU”

&nbsp; [“iata”]=\>

&nbsp; string(0) “”

&nbsp; [“name”]=\>

&nbsp; string(14) “Bauchi Airport”

&nbsp; [“city”]=\>

&nbsp; string(6) “Bauchi”

&nbsp; [“country”]=\>

&nbsp; string(2) “NG”

&nbsp; [“region”]=\>

&nbsp; string(5) “NG-BA”

&nbsp; [“tz”]=\>

&nbsp; string(0) “”

&nbsp; [“elevation”]=\>

&nbsp; int(1998)

&nbsp; [“lat”]=\>

&nbsp; float(10.294402)

&nbsp; [“lon”]=\>

&nbsp; float(9.816672)

}

and for&nbsp;DNSU

array(10) {

&nbsp; [“icao”]=\>

&nbsp; string(6) “NG-QRW”

&nbsp; [“iata”]=\>

&nbsp; string(3) “QRW”

&nbsp; [“name”]=\>

&nbsp; string(13) “Warri Airport”

&nbsp; [“city”]=\>

&nbsp; string(5) “Warri”

&nbsp; [“country”]=\>

&nbsp; string(2) “NG”

&nbsp; [“region”]=\>

&nbsp; string(5) “NG-DE”

&nbsp; [“tz”]=\>

&nbsp; string(0) “”

&nbsp; [“elevation”]=\>

&nbsp; int(242)

&nbsp; [“lat”]=\>

&nbsp; float(5.59611)

&nbsp; [“lon”]=\>

&nbsp; float(5.81778)

}

and this for&nbsp;DNGO

&nbsp;

array(10) {

&nbsp; [“icao”]=\>

&nbsp; string(7) “NG-0003”

&nbsp; [“iata”]=\>

&nbsp; string(3) “GMO”

&nbsp; [“name”]=\>

&nbsp; string(35) “Gombe Lawanti International Airport”

&nbsp; [“city”]=\>

&nbsp; string(5) “Gombe”

&nbsp; [“country”]=\>

&nbsp; string(2) “NG”

&nbsp; [“region”]=\>

&nbsp; string(5) “NG-GO”

&nbsp; [“tz”]=\>

&nbsp; string(0) “”

&nbsp; [“elevation”]=\>

&nbsp; int(1590)

&nbsp; [“lat”]=\>

&nbsp; float(10.298889)

&nbsp; [“lon”]=\>

&nbsp; float(10.9)

}

---

<div class="post-metadata">

**Author:** ![ProAvia](https://forum.phpvms.net/user_avatar/forum.phpvms.net/proavia/32/135_2.png) [@ProAvia](https://forum.phpvms.net/u/ProAvia)\
**Post date:** [June 2, 2025, 4:02pm UTC](https://forum.phpvms.net/t/using-standard-php-curl-for-vacentral-api-call/14125/7 "2025-06-02T16:02:16Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![LesJar](https://forum.phpvms.net/letter_avatar_proxy/v4/letter/l/ad7895/32.png) [@LesJar](https://forum.phpvms.net/u/LesJar)\
**Post date:** [June 3, 2025, 7:57am UTC](https://forum.phpvms.net/t/using-standard-php-curl-for-vacentral-api-call/14125/8 "2025-06-03T07:57:43Z")

</div>

> 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

---

<div class="post-metadata">

**Author:** ![DisposableHero](https://forum.phpvms.net/user_avatar/forum.phpvms.net/disposablehero/32/1457_2.png) [@DisposableHero](https://forum.phpvms.net/u/DisposableHero)\
**Post date:** [June 3, 2025, 8:05am UTC](https://forum.phpvms.net/t/using-standard-php-curl-for-vacentral-api-call/14125/9 "2025-06-03T08:05:43Z")

</div>

> 4 minutes ago, LesJar said:
> 
> I have posted the errors I found on trying 3402 airports

&nbsp;

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.

---

<div class="post-metadata">

**Author:** ![LesJar](https://forum.phpvms.net/letter_avatar_proxy/v4/letter/l/ad7895/32.png) [@LesJar](https://forum.phpvms.net/u/LesJar)\
**Post date:** [June 3, 2025, 8:31am UTC](https://forum.phpvms.net/t/using-standard-php-curl-for-vacentral-api-call/14125/10 "2025-06-03T08:31:55Z")

</div>

> 25 minutes ago, DisposableHero said:
> 
> &nbsp;
> 
> 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.

&nbsp;

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

&nbsp;

---

<div class="post-metadata">

**Author:** ![ProAvia](https://forum.phpvms.net/user_avatar/forum.phpvms.net/proavia/32/135_2.png) [@ProAvia](https://forum.phpvms.net/u/ProAvia)\
**Post date:** [June 3, 2025, 4:24pm UTC](https://forum.phpvms.net/t/using-standard-php-curl-for-vacentral-api-call/14125/11 "2025-06-03T16:24:54Z")

</div>

Check this github repository for the airports in question

[https://github.com/mwgg/Airports](https://github.com/mwgg/Airports)

You can open an issue there for needed corrections.

&nbsp;

Also check&nbsp;[https://ourairports.com/](https://ourairports.com/)

&nbsp;

The vaCentral DB gets updated from time to time.

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

&nbsp;

&nbsp;

---

<div class="post-metadata">

**Author:** ![LesJar](https://forum.phpvms.net/letter_avatar_proxy/v4/letter/l/ad7895/32.png) [@LesJar](https://forum.phpvms.net/u/LesJar)\
**Post date:** [June 3, 2025, 4:31pm UTC](https://forum.phpvms.net/t/using-standard-php-curl-for-vacentral-api-call/14125/12 "2025-06-03T16:31:26Z")

</div>

> 5 minutes ago, ProAvia said:
> 
> Check this github repository for the airports in question
> 
> [https://github.com/mwgg/Airports](https://github.com/mwgg/Airports)
> 
> You can open an issue there for needed corrections.
> 
> &nbsp;
> 
> Also check&nbsp;[https://ourairports.com/](https://ourairports.com/)
> 
> &nbsp;
> 
> The vaCentral DB gets updated from time to time.
> 
> Last I knew, the above data sources were used - but this may have changed.
> 
> &nbsp;
> 
> &nbsp;

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

---

<div class="post-metadata">

**Author:** ![ProAvia](https://forum.phpvms.net/user_avatar/forum.phpvms.net/proavia/32/135_2.png) [@ProAvia](https://forum.phpvms.net/u/ProAvia)\
**Post date:** [June 3, 2025, 6:29pm UTC](https://forum.phpvms.net/t/using-standard-php-curl-for-vacentral-api-call/14125/13 "2025-06-03T18:29:58Z")

</div>

> 1 hour ago, LesJar said:
> 
> Will check that out but of course Vacentrsl needs the database updated&nbsp;

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

---

<div class="post-metadata">

**Author:** ![DisposableHero](https://forum.phpvms.net/user_avatar/forum.phpvms.net/disposablehero/32/1457_2.png) [@DisposableHero](https://forum.phpvms.net/u/DisposableHero)\
**Post date:** [June 4, 2025, 8:20am UTC](https://forum.phpvms.net/t/using-standard-php-curl-for-vacentral-api-call/14125/14 "2025-06-04T08:20:00Z")

</div>

> 13 hours ago, ProAvia said:
> 
> It gets updated from time to time.&nbsp;  
> But if the source DB isn’t updated, neither will vaCentral - even if a vaCentral update is done.&nbsp;  
> &nbsp;

&nbsp;

That is the main problem.

&nbsp;

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.)

&nbsp;

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)

---

<div class="post-metadata">

**Author:** ![LesJar](https://forum.phpvms.net/letter_avatar_proxy/v4/letter/l/ad7895/32.png) [@LesJar](https://forum.phpvms.net/u/LesJar)\
**Post date:** [June 4, 2025, 9:17am UTC](https://forum.phpvms.net/t/using-standard-php-curl-for-vacentral-api-call/14125/15 "2025-06-04T09:17:11Z")

</div>

> 55 minutes ago, DisposableHero said:
> 
> &nbsp;
> 
> That is the main problem.
> 
> &nbsp;
> 
> 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.)
> 
> &nbsp;
> 
> 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

&nbsp;

I have done similar for GeoNames Airport data&nbsp;

&nbsp;
