Jump to content

Acars data etc from different sites(solved)


mattsmith

Recommended Posts

Well first you'd have to ask the airline's if they're ok with it, then you can proceed.

Second, the ACARS function that outputs the data is found here https://github.com/DavidJClark/phpvms_5.5.x/blob/master/core/modules/ACARS/ACARS.php#L52

And luckily that returns an array of data which is easy to merge.

I haven't tested it and have probably forgotten something, but you can build on something like this

$allflights = array();
$myairline = ACARSData::GetACARSData();
// If you have multiple airlines, you could also loop this through
$another_airline = json_decode(file_get_contents('va_url_here'), true); // specify true for an array conversion
$allflights = array_merge($myairline, $another_airline);

foreach($allflights as $flight) {
...

You'd also have to verify what data is actually being returned to make it all fit together.

Edited by web541
  • Like 1
Link to comment
Share on other sites

On 02/01/2017 at 10:24 PM, web541 said:

Well first you'd have to ask the airline's if they're ok with it, then you can proceed.

Second, the ACARS function that outputs the data is found here https://github.com/DavidJClark/phpvms_5.5.x/blob/master/core/modules/ACARS/ACARS.php#L52

And luckily that returns an array of data which is easy to merge.

I haven't tested it and have probably forgotten something, but you can build on something like this


$allflights = array();
$myairline = ACARSData::GetACARSData();
// If you have multiple airlines, you could also loop this through
$another_airline = json_decode(file_get_contents('va_url_here'), true); // specify true for an array conversion
$allflights = array_merge($myairline, $another_airline);

foreach($allflights as $flight) {
...

You'd also have to verify what data is actually being returned to make it all fit together.

Can't get it to work, any idea?

Link to comment
Share on other sites

Im just learning coding so i haven,t got any yet I've just been using this and changing things in core/modules/ACARS

 

$allflights = array();
$myairline = ACARSData::GetACARSData();
// If you have multiple airlines, you could also loop this through
$another_airline = json_decode(file_get_contents('va_url_here'), true); // specify true for an array conversion
$allflights = array_merge($myairline, $another_airline);

foreach($allflights as $flight) {
...

 

Link to comment
Share on other sites

Ah yes, that was just a rough sketch, you'd need to adapt it a bit. Good news is, once the data is in one array, it should be able to just join up and display it in the template (hopefully, unless phpVMS is routing the ACARS through another place as well).

And how many virtual airlines do you need to have on the ACARS map? (1 or more)

Link to comment
Share on other sites

Ok, I'll re-instate that you must have permission from them to do this first, but then proceed.

I've just tested this and it works

Replace this

$flights = ACARSData::GetACARSData();

with this (in core/ACARS/ACARS.php)

/////////////////////////////////////////////////////////////
// UPDATED ACARS DATA
/////////////////////////////////////////////////////////////
$myflights = ACARSData::GetACARSData();
if(!$myflights) $myflights = array();
$other_airlines = array(
	json_decode(file_get_contents('http://yourvaurl.com/action.php/acars/data', true)),
);

// This will get all the other airlines data
$flights = array();
foreach($other_airlines as $airline) {
  foreach($airline as $a) {
  $flights[] = $a;
  }
}

$flights = array_merge($flights, $myflights);
/////////////////////////////////////////////////////////////
// END UPDATED ACARS DATA
/////////////////////////////////////////////////////////////

And replace http://yourvaurl.com/ with the va url which you are trying to retrieve, and for more airlines, just copy that line (json_decode(...) and again change the url and it should work (although I've only tested it with one airline, but it should work as expected).

Edited by web541
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...