Jump to content

[Free] FlightAware Schedule Puller


RamiAbouZahra

Recommended Posts

Hey, I noticed that the "demand" for this thing seems to be quite "high".

I created a tool that pulls data from flightaware's api and stores them into a csv file which phpvms can accept :)

There is still plenty to do (I need to add so you can quickly change airline to pull data from).

You need to create an account at fligthtaware and then change the variables in the index.php file, then you're good to go!

 

How does it work? Well, unlike some other services, it doesn't use AirlineFlightSchedules query in the api since that is a paid service, we want to keep it completely free.

It uses AirportBoards and then adds the parameter of only including the airline you want and then takes the data which is looked after (airline code, flightnumber, tailnumber etc) and prints them out into tables and into one big csv file. It takes only arriving and departing aircrafts, since when doing scheduled ones, missing info was inserted.

Since it's using AirportBoards, that means that you have to run this script every day for a week on all the hubs (don't worry, you can change which airport to capture data from) to capture all the data.

 

You can check and contribute to the project at my github:)

  • Thanks 1
Link to comment
Share on other sites

Update:

 

-Forgot to convert AM/PM to 24hr, fixed

- Includes total flight time

 

Next update will check if there is a route filed and print that to the table and csv file. Possibly going to add the same thing for the altitude, but I am not sure if I should to it flight level or just pure altitude. Maybe I'll integrate a checkbox for that :)

Link to comment
Share on other sites

40 minutes ago, ncd200 said:

but how to install it?

Great thing to have, Thanks for your hard work

You don't install it on phpvms (although you can, but I am not going to sit and write a tutorial on that :p), you run it and get a schedule.csv which you can import to phpvms.

Right now, it doesn't get all the schedules, you need to run at a couple of times and whatnot but I am working on it :)

 

As for the api key, you can create a flightaware account, then go to this (https://flightaware.com/commercial/flightxml/key) link and then copy credentials to the php file :)

 

Thanks for trying it out ;)

Link to comment
Share on other sites

22 minutes ago, magicflyer said:

Been a long time since I looked at FlightAware. Their new pricing structure looks a lot more reasonable than what they had last time. Have you considered doing a chron job to get the schedules for the most popular airlines?

I have considered it, but it's not the best solution (if a code already exists, it's going to append it twice which isn't good).

This isn't my top priority, but it's up there.

Link to comment
Share on other sites

I'm using something like that.
I created my own php script and i run it with a cronjob.

It keeps my schedule databse up to date and I grab data from Flightaware totally free.

Basically, the scrip go to 

 $ch = curl_init("http://flightaware.com/live/fleet/".$code."?;offset=".($i*40)."&sort=ASC;order=actualdeparturetime");

$code is defined by whatever you want ( WJA-JBU-AAL-DAL...)

The script is connected directly with your phpvms database so it updates/upload all datas in there.

If flight does not exist = it creates
If flight exist = check for update
if exist and up to date = do nothing

and also, if flight do not receive any update for x days, then delete it

So you understand here that my schedule is always up to date and synchroinized with flightaware :)
 

I'm pretty proud of it because i'm not a php expert and I'm working on it for one year lol
I used flightaware API before but I found out a way to get data for free...

  • Like 1
Link to comment
Share on other sites

1 minute ago, elfrost said:

I'm using something like that.
I created my own php script and i run it with a cronjob.

It keeps my schedule databse up to date and I grab data from Flightaware totally free.

Basically, the scrip go to 


 $ch = curl_init("http://flightaware.com/live/fleet/".$code."?;offset=".($i*40)."&sort=ASC;order=actualdeparturetime");

$code is defined by whatever you want ( WJA-JBU-AAL-DAL...)

The script is connected directly with your phpvms database so it updates/upload all datas in there.

If flight does not exist = it creates
If flight exist = check for update
if exist and up to date = do nothing

and also, if flight do not receive any update for x days, then delete it

So you understand here that my schedule is always up to date and synchroinized with flightaware :)
 

I'm pretty proud of it because i'm not a php expert and I'm working on it for one year lol
I used flightaware API before but I found out a way to get data for free...

Looks and sounds awesome! I see what you did there without using the api <_< (I'm not even mad that's impressive).

This is just a project I did to learn to work with api's and curl in php, but it's pretty cool what you can do!

Link to comment
Share on other sites

4 minutes ago, RamiAbouZahra said:

Looks and sounds awesome! I see what you did there without using the api <_< (I'm not even mad that's impressive).

This is just a project I did to learn to work with api's and curl in php, but it's pretty cool what you can do!

pretty cool indeed :)

Here a code I have written long time ago and I do not use anymore. not sure if it still working
 

<?php

$options = array(
   'trace' => true,
   'exceptions' => 0,
   'login' => '',
   'password' => ''
);
$client = new SoapClient('http://flightxml.flightaware.com/soap/FlightXML2/wsdl', $options);

$params = array(
   'fleet' => 'WJA',
   'howMany' => 15,   
   'offset' => 0,
   'maxDepartureAge' => '3 days',
   'maxFileAge' =>  '5 days'    
);

$data = array();



$output = fopen('php://output', 'w');


$result = $client->FleetScheduled($params);
$result1 = $client->RoutesBetweenAirportsEx($params);
$i = 0;
$data = array();
    foreach ($result->FleetScheduledResult->scheduled as $flightObj)
	foreach ($result1->RoutesBetweenAirportsExResult->data as $flightObj) {

      $data[] = $flightObj;
      $i++;

    
    $origdestarr[]=$flightObj->origin."_".$flightObj->destination;
    
 
    }
   
     
     
if (is_soap_fault($result)) {
  
   echo 'ERROR: ' . $result->getMessage() . "\n";
   die();
} 





  function objectToArray($d) {
    if (is_object($d)) {
      // Gets the properties of the given object
      // with get_object_vars function
      $d = get_object_vars($d);
    }
    
    if (is_array($d)) {
      /*
      * Return array converted to object
      * Using __FUNCTION__ (Magic constant)
      * for recursive call
      */
      return array_map(__FUNCTION__, $d);
    }
    else {
      // Return array
      return $d;
    }
  }
$my = objectToArray($data);
function array2csv(array &$array)
{
   if (count($array) == 0) {
     return null;
   }
   ob_start();
   $df = fopen("php://output", 'w');
   fputcsv($df, array_keys(reset($array)));
   foreach ($array as $row) {
      fputcsv($df, $row);
   }
   fclose($df);
   return ob_get_clean();
}





function download_send_headers($filename) {
    // disable caching
    $now = gmdate("D, d M Y H:i:s");
    header("Expires: Tue, 03 Jul 2001 06:00:00 GMT");
    header("Cache-Control: max-age=0, no-cache, must-revalidate, proxy-revalidate");
    header("Last-Modified: {$now} GMT");

    // force download  
    header("Content-Type: application/force-download");
    header("Content-Type: application/octet-stream");
    header("Content-Type: application/download");

    // disposition / encoding on response body
    header("Content-Disposition: attachment;filename={$filename}");
    header("Content-Transfer-Encoding: binary");
}

date_default_timezone_set("UTC");
download_send_headers("data_export_WJA_" . date("Y-m-d") . ".csv");
echo array2csv($my);
die();
?>

 

  • Thanks 1
Link to comment
Share on other sites

5 minutes ago, elfrost said:

pretty cool indeed :)

Here a code I have written long time ago and I do not use anymore. not sure if it still working
 

 

Quickly skimmed through it, afaik, flightxml2 is deprecated :/ But hey! Conversion to flightxm3 is possible :) Just a bit curious how using "w" worked out, did it overwrite entries in the csv file? That's what happened when I used it, I could only get the last data in the array so I used option "a" instead which worked ;) 

Link to comment
Share on other sites

42 minutes ago, RuiMiguel said:

this error is because on two lines after <? missing php

line 66 and 148

Hate to shatter your dreams but that's not why... You can close and open multiple times in a php file (otherwise I wouldn't be able to print the data into the table :)).

That issue should not be existing if you properly copied and pasted and made sure that all the syntax is included in the new file.
I also have to state that this should not be run on the server, don't paste this anywhere on the website.

I am also curious which php version people whom are getting this error are running.

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