[Module Request] AirCharts.org charts in Briefing page. (API Available)

Hello ,

As all of us must be knowing , the default briefing doesn’t retrieve charts out of USA ARTCCs.

I have found a website called “AirCharts.org” with an open free API that lists all charts according to ICAO worldwide.

Unfortunately , I don’t have much PHP knowledge. If someone could code this , it would be a great help to all virtual airlines all over the world.

API
AirCharts' new, open API is now available for public use. Use of the API is in accordance with the API Agreement.
Usage:
Airport Information and Charts: http://api.aircharts.org/Airport/(ICAO).(format)
List of Airports and Charts: http://api.aircharts.org/Airport/(ICAO),(ICAO),(ICAO).(format) [up to 15]
Available formats: JSON (default), XML.
Examples:
http://api.aircharts.org/Airport/KNPA.json
http://api.aircharts.org/Airport/KPNS,KNPA,KNDZ,KNSE,KJKA.json
http://api.aircharts.org/Airport/KNPA,KPNS,KNDZ,KNSE,KJKA.xml

EDIT: Original text

For now, you can just put this in a module called

core/modules/Aircharts/Aircharts.php

<?php
class Aircharts extends CodonModule {
public $title = 'Aircharts';
public function index() {

}

public function getCharts($icao = '') {
$icao = DB::escape($icao);
$responsetype = '.json'; // Change this to .XML if you really want
$apiurl = 'http://api.aircharts.org/Airport/'.$icao.$responsetype;
$obj = json_decode(file_get_contents($apiurl), true);
foreach($obj as $o) {
echo '<strong>Charts for '.$icao.'</strong>';
echo '<br />';
foreach($o['charts'] as $c) {
echo $c['name'].' - <a href="'.$c['url'].'" target="_blank">Link Here</a>';
echo '<br />';
}
}
}
}

And then in your url go to http://yourvaurl.com…/getCharts/KJFK and it should output the charts (change KJFK to any ICAO).

EDIT:: I saw you wanted to show this in your schedule briefing, for starters (without a template made), you can just replace this

<tr style="background-color: #333; color: #FFF;">
<td>Charts for <?php echo $schedule->depicao?></td>
<td>Charts for <?php echo $schedule->arricao?></td>
</tr>
<tr align="center">
<td width="50%" valign="top">
<a href="http://www.airnav.com/airport/<?php echo $schedule->depicao?>#ifr" target="_blank">
<img border="0" src="http://flightaware.com/resources/airport/<?php echo $schedule->depicao?>/APD/AIRPORT+DIAGRAM/png"
width="387px" height="594px" alt="No chart available" /></a>
</td>
<td width="50%" valign="top">
<a href="http://www.airnav.com/airport/<?php echo $schedule->arricao?>#ifr" target="_blank">
<img border="0" src="http://flightaware.com/resources/airport/<?php echo $schedule->arricao?>/APD/AIRPORT+DIAGRAM/png"
width="387px" height="594px" alt="No chart available" /></a>
</td>

</tr>

With this

<tr style="background-color: #333; color: #FFF;">
<td>Charts for <?php echo $schedule->depicao?></td>
<td>Charts for <?php echo $schedule->arricao?></td>
</tr>
<tr align="center">
<td width="50%" valign="top">
<?php MainController::Run('Aircharts', 'getCharts', $schedule->depicao); ?>
</td>
<td width="50%" valign="top">
<?php MainController::Run('Aircharts', 'getCharts', $schedule->arricao); ?>
</td>

</tr>

And it will show all charts found in a list

EDIT: I have uploaded the complete module now onto github https://github.com/w…AirchartsModule

Make sure you are familiar with the aircharts license agreement then follow the instructions to install

1 Like

This works perfectly. Thank you very very very much.

This module was working perfectly a week or two ago. Today I am getting the following errors when attempting to access an airport that AirCharts supplies charts for.

Warning: file\_get\_contents(): Peer certificate CN=`nameitcreateit.com' did not match expected CN=`api.aircharts.org' in /home/xxxx/public\_html/xxxx/phpvms/core/modules/Aircharts/Aircharts.php on line 40 Warning: file\_get\_contents(): Failed to enable crypto in /home/xxxx/public\_html/xxxx/phpvms/core/modules/Aircharts/Aircharts.php on line 40 Warning: file\_get\_contents(http://api.aircharts.org/Airport/KLAS.json): failed to open stream: operation failed in /home/xxxx/public\_html/xxxx/phpvms/core/modules/Aircharts/Aircharts.php on line 40

Line 40 reads:

 $obj = json\_decode(file\_get\_contents($apiurl), true);

It looks like the AirCharts site has the ability to use ‘https’ instead of ‘http’. I tried changing the ‘http’ entries to ‘https’ in …/modules/Aircharts/Aircharts.php and received the same error.

Also, looks like version 2 of the API was released (https://api.aircharts.org/). I tried changing the 3 $apiurl lines (17, 28, 39) in Aircharts.php to reflect this change and continued to receive the same error.

The only item on my site that changed is we added SSL (https). But after getting that all set up, everything (including AirCharts) worked fine - until today.

Any help is much appreciated.

Also just noticed in Error_log a bunch of similar errors starting on 12/17/2017.

[22-Dec-2017 10:17:37 America/Los\_Angeles] PHP Warning: file\_get\_contents(): Failed to enable crypto in /home/xxxx/public\_html/xxxx/phpvms/core/modules/Aircharts/Aircharts.php on line 18 [22-Dec-2017 10:17:37 America/Los\_Angeles] PHP Warning: file\_get\_contents(http://api.aircharts.org/Airport/KASE.json): failed to open stream: operation failed in /home/xxxx/public\_html/xxxx/phpvms/core/modules/Aircharts/Aircharts.php on line 18 [22-Dec-2017 10:17:38 America/Los\_Angeles] PHP Warning: file\_get\_contents(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:SSL3\_GET\_SERVER\_CERTIFICATE:certificate verify failed in /home/xxxx/public\_html/xxxx/phpvms/core/modules/Aircharts/Aircharts.php on line 18 [22-Dec-2017 10:17:38 America/Los\_Angeles] PHP Warning: file\_get\_contents(): Failed to enable crypto in /home/xxxx/public\_html/xxxx/phpvms/core/modules/Aircharts/Aircharts.php on line 18 [22-Dec-2017 10:17:38 America/Los\_Angeles] PHP Warning: file\_get\_contents(http://api.aircharts.org/Airport/KDEN.json): failed to open stream: operation failed in /home/xxxx/public\_html/xxxx/phpvms/core/modules/Aircharts/Aircharts.php on line 18 [22-Dec-2017 10:27:42 America/Los\_Angeles] PHP Warning: file\_get\_contents(): Peer certificate CN=`nameitcreateit.com' did not match expected CN=`api.aircharts.org' in /home/xxxx/public\_html/xxxx/phpvms/core/modules/Aircharts/Aircharts.php on line 18 [22-Dec-2017 10:27:42 America/Los\_Angeles] PHP Warning: file\_get\_contents(): Failed to enable crypto in /home/xxxx/public\_html/xxxx/phpvms/core/modules/Aircharts/Aircharts.php on line 18

The first 4 occur from 12/17 to the date/time shown. The later 3 show from that date/time to present.

6 hours ago, ProAvia said:

This module was working perfectly a week or two ago. Today I am getting the following errors when attempting to access an airport that AirCharts supplies charts for.

Warning: file_get_contents(): Peer certificate CN=nameitcreateit.com' did not match expected CN=api.aircharts.org’ in /home/xxxx/public_html/xxxx/phpvms/core/modules/Aircharts/Aircharts.php on line 40 Warning: file_get_contents(): Failed to enable crypto in /home/xxxx/public_html/xxxx/phpvms/core/modules/Aircharts/Aircharts.php on line 40 Warning: file_get_contents(http://api.aircharts.org/Airport/KLAS.json): failed to open stream: operation failed in /home/xxxx/public_html/xxxx/phpvms/core/modules/Aircharts/Aircharts.php on line 40

Line 40 reads:

$obj = json_decode(file_get_contents($apiurl), true);

It looks like the AirCharts site has the ability to use ‘https’ instead of ‘http’. I tried changing the ‘http’ entries to ‘https’ in …/modules/Aircharts/Aircharts.php and received the same error.

Also, looks like version 2 of the API was released (https://api.aircharts.org/). I tried changing the 3 $apiurl lines (17, 28, 39) in Aircharts.php to reflect this change and continued to receive the same error.

The only item on my site that changed is we added SSL (https). But after getting that all set up, everything (including AirCharts) worked fine - until today.

Any help is much appreciated.

Go to the  and re-download the module, I have updated it to the API Version 2 and also have a workaround for the SSL Issue (temporary). It should work now.

1 Like

Thanks for the quick update Web541… I will install the update tomorrow. Really appreciate your time and effort!!

I’m getting this on requesting for non-US charts:

Warning: Invalid argument supplied for foreach() in /storage/ssd3/285/3946285/public\_html/core/templates/aircharts/aircharts\_chartslist.php on line 49

US charts work fine

19 hours ago, web541 said:

Go to the  and re-download the module, I have updated it to the API Version 2 and also have a workaround for the SSL Issue (temporary). It should work now.

Thank you - works great!

My basic understanding of the temporary SSL workaround is that it bypasses the SSL check - is that correct?

17 hours ago, thefiercepilot said:

I’m getting this on requesting for non-US charts:

Warning: Invalid argument supplied for foreach() in /storage/ssd3/285/3946285/public_html/core/templates/aircharts/aircharts_chartslist.php on line 49

US charts work fine

Can you give me an ICAO that does this, their supported airports are listed here https://www.aircharts.org/

 

4 minutes ago, ProAvia said:

Thank you - works great!

My basic understanding of the temporary SSL workaround is that it bypasses the SSL check - is that correct?

Yes it bypasses SSL verification only for the charts, haven’t figured out a way to use file_get_contents with SSL correctly (cURL could work). This is something I’ve never seen before. It’s possible that their API doesn’t support secure connections as of yet (hence why it says “Your connection is not private” when visiting their API)

1 Like

17 hours ago, thefiercepilot said:

I’m getting this on requesting for non-US charts:

Warning: Invalid argument supplied for foreach() in /storage/ssd3/285/3946285/public_html/core/templates/aircharts/aircharts_chartslist.php on line 49

US charts work fine

Actually, redownload the module, I’ve fixed this now.

1 Like

14 minutes ago, web541 said:

Actually, redownload the module, I’ve fixed this now.

That fixed the error I was seeing in the error_log file. Thanks!

1 Like

Got it. I was trying OMDG and VIDP that’s why the errors. Thanks for a great module!

1 Like