RamiAbouZahra Posted November 18, 2017 Report Posted November 18, 2017 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 1 Quote
RamiAbouZahra Posted November 19, 2017 Author Report Posted November 19, 2017 Update: Added so you can index by airline Next update will remove the AM/PM tags 1 Quote
RamiAbouZahra Posted November 19, 2017 Author Report Posted November 19, 2017 (edited) Update: - Removed AM/PM tags, now it's easier to import to phpvms! Next update will have total flight time Edited November 20, 2017 by RamiAbouZahra Quote
RamiAbouZahra Posted November 20, 2017 Author Report Posted November 20, 2017 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 Quote
ncd200 Posted November 20, 2017 Report Posted November 20, 2017 but how to install it? Great thing to have, Thanks for your hard work Quote
ncd200 Posted November 20, 2017 Report Posted November 20, 2017 I need an API key, that one I must buy from flightaware? Quote
RamiAbouZahra Posted November 20, 2017 Author Report Posted November 20, 2017 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 Quote
magicflyer Posted November 20, 2017 Report Posted November 20, 2017 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? Quote
RamiAbouZahra Posted November 20, 2017 Author Report Posted November 20, 2017 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. Quote
ncd200 Posted November 21, 2017 Report Posted November 21, 2017 but it is not free as you sugegsted? When I open the lin k you provided i must fill in a form with creditcard information to buy the key. Rick Quote
RamiAbouZahra Posted November 21, 2017 Author Report Posted November 21, 2017 46 minutes ago, ncd200 said: but it is not free as you sugegsted? When I open the lin k you provided i must fill in a form with creditcard information to buy the key. Rick Could be wrong link, my bad http://flightaware.com/commercial/flightxml/ scroll down to get api key (you get 500 queries free) Quote
ncd200 Posted November 21, 2017 Report Posted November 21, 2017 Also then i am redirected to the page where i need to pay Quote
RamiAbouZahra Posted November 21, 2017 Author Report Posted November 21, 2017 Just now, ncd200 said: Also then i am redirected to the page where i need to pay Well, have you created an account, verified email and logged in? Quote
elfrost Posted November 21, 2017 Report Posted November 21, 2017 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... 1 Quote
RamiAbouZahra Posted November 21, 2017 Author Report Posted November 21, 2017 28 minutes ago, ncd200 said: yes, i did https://uk.flightaware.com/commercial/flightxml/signup.rvt?product_type=1 wrong link (again, sorry :p) Quote
RamiAbouZahra Posted November 21, 2017 Author Report Posted November 21, 2017 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! Quote
elfrost Posted November 21, 2017 Report Posted November 21, 2017 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(); ?> 1 Quote
RamiAbouZahra Posted November 21, 2017 Author Report Posted November 21, 2017 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 Quote
elfrost Posted November 21, 2017 Report Posted November 21, 2017 honestly, i did not use for long time so maybe i would get some issues. but it could be a good starting point I guess or another way to grab those datas 1 Quote
RamiAbouZahra Posted November 21, 2017 Author Report Posted November 21, 2017 2 minutes ago, elfrost said: honestly, i did not use for long time so maybe i would get some issues. but it could be a good starting point I guess or another way to grab those datas Yep, good intentions I guess this thread can be everything about pulling flightdata for free for import to phpvms 1 Quote
reaperz Posted November 22, 2017 Report Posted November 22, 2017 Getting this Parse error: syntax error, unexpected '}', expecting end of file in index.php on line 216 removed 2 } which got rid of error but script just spits out lines of code Quote
RamiAbouZahra Posted November 22, 2017 Author Report Posted November 22, 2017 (edited) if(isset($_POST['airline'])) { That is from the first if command, how can you not have that? Did you download the code from my github or did you copy paste? Make sure to include the html code in the top of the document, otherwise the $_POST will return an index error Edited November 22, 2017 by RamiAbouZahra Quote
RuiMiguel Posted November 22, 2017 Report Posted November 22, 2017 this error is because on two lines after <? missing php line 66 and 148 Quote
RamiAbouZahra Posted November 22, 2017 Author Report Posted November 22, 2017 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. Quote
RuiMiguel Posted November 22, 2017 Report Posted November 22, 2017 that's how I solved the mistake Quote
RamiAbouZahra Posted November 22, 2017 Author Report Posted November 22, 2017 7 minutes ago, RuiMiguel said: that's how I solved the mistake Hey, as we say here at phpvms, if it's stupid, but it works, it ain't stupid Quote
Administrators Nabeel Posted November 29, 2017 Administrators Report Posted November 29, 2017 On 11/22/2017 at 2:07 PM, RamiAbouZahra said: Hey, as we say here at phpvms, if it's stupid, but it works, it ain't stupid A good landing is one you walk away from. I just moved this to the right forum Quote
RamiAbouZahra Posted November 29, 2017 Author Report Posted November 29, 2017 2 minutes ago, Nabeel said: A good landing is one you walk away from. I just moved this to the right forum A great landing is one where you can use the plane again. +1 for the correct forum Quote
Michael2015 Posted December 7, 2017 Report Posted December 7, 2017 how do you get it to pull and work tho 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.