LesJar Posted Saturday at 05:09 PM Report Posted Saturday at 05:09 PM 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. Quote
LesJar Posted Sunday at 07:20 AM Author Report Posted Sunday at 07:20 AM 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) // } ?> Quote
DisposableHero Posted Sunday at 11:28 AM Report Posted Sunday at 11:28 AM 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. Quote
LesJar Posted Monday at 02:24 PM Author Report Posted Monday at 02:24 PM 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) } Quote
LesJar Posted Monday at 02:28 PM Author Report Posted Monday at 02:28 PM 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) } Quote
LesJar Posted Monday at 02:34 PM Author Report Posted Monday at 02:34 PM 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) } Quote
Administrators ProAvia Posted Monday at 04:02 PM Administrators Report Posted Monday at 04:02 PM The issue is likely in the source data vacentral uses for airport lookup. Quote
LesJar Posted 22 hours ago Author Report Posted 22 hours ago 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 Quote
DisposableHero Posted 22 hours ago Report Posted 22 hours ago 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. Quote
LesJar Posted 21 hours ago Author Report Posted 21 hours ago 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 Quote
Administrators ProAvia Posted 13 hours ago Administrators Report Posted 13 hours ago 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. Quote
LesJar Posted 13 hours ago Author Report Posted 13 hours ago 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 Quote
Administrators ProAvia Posted 11 hours ago Administrators Report Posted 11 hours ago 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. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.