I’m trying to use the FlightAware API, however it doesn’t work. It just returns: Fatal error: require_once() [function.require]: Failed opening required ‘SOAP/Client.php’ (include_path=‘.:/usr/lib/php:/usr/local/lib/php’)
I know that I have Soap installed because I used phpinfo() and cPanel to verify. I also know that the include path is set properly. Any help is appreciated. Thanks!
That is a PHP installation/configuration issue, and is not specific to our API. Your hosting provider needs to ensure that all of the necessary files for SOAP-Client are actually present. It looks like they compiled PHP with that option, but didn’t actually install all of the files associated with it.
Thank you! There are no errors and the data seems to return properly, however it doesn’t go into the MySQL database (the database is being connected to).
You probably want to quote and escape those arguments. php.net/mysqli.real-escape-string.php Alternatively use bound arguments in your query. But you are now asking questions that are unrelated to FlightXML and relate to general PHP development.
Thanks for that. I’m not too worried about escapes because I have other security for that. Now I’ve figured out that the 2nd query to FlightAware isn’t working. It just returns this:
The “Search” method does not return the estimated time enroute, however you can subsequently call “FlightInfoEx” (with the faFlightID returned by Search as the argument) and it will return the “filed_ete”.
The estimated distance is a little harder to determine. You could compute the “great circle” distance between the latitude/longitude of the origin and destination airports and get a pretty accurate number for longer flights. You could alternatively try using the “DecodeFlightRoute” method with the faFlightID and it will return a list of latitude/longitude of all of the points along the filed flight route, which you can compute the distance between each segment and add up the total. Be aware that DecodeFlightRoute is not able to decode all flight routes, particularly ones that are not entirely without the United States, so you may need to fall back on the great circle distance between simply the origin and destination.
AirportInfo will tell you details about any airport code, including its latitude and longitude. You can cache the results from this function in your database to avoid future lookups.
Once you have the latitude/longitude of both airports, you can calculate the great circle distance between them yourself (the math is not too difficult), or you can use the LatLongsToDistance method.
Sorry to bother you so much with this and I really appreciate the help so far. The distance gets put into MySQL but the numbers are way off. No other data from FlightInfoEx gets put into MySQL. Here’s the code:
I recommend you try just using the LatLongsToDistance method and compare your output to that. If there is a significant difference, then your great circle implementation is defective.
If you’re not getting any output from the PHP page, try printing more output earlier or more frequently.
Well, I’m not sure that’s the issue I’m trying to solve. The issue is that I don’t think soap is pulling the FlightInfoEx information and if it is then its not transferring to the variables for some freaking reason… and I just realized that I was using FlightXML v1. Well, now I’m back to this:
You need to try using print_r() more liberally when you have problems. You seem to be write long sections of code without checking that earlier parts are fully working. You might want to also do some error checking to ensure that you receive any results back too.
I’ve been trying to use print_r, but I don’t understand these stacks very well. Here’s the AirportInfo and FlightInfoEx dishing out errors for I have no clue why:
It’s hard for me to determine what arguments you were supplying since you are only pasting the response from the server.
However, from the server logs I can see that you were calling AirportInfo with no airport code as the argument (or were passing the argument incorrectly). Be sure you are specifying the argument name the same way it is specified in the documentation. It should be “airportCode”
I do not see any attempts by you to call FlightInfoEx in the server logs, so you are probably forming the request incorrectly to even be interpreted by the server.
Well, that’s just the problem because I am supplying an airport code ($orig and $dest; and I’ve checked to make sure they are in fact airport codes). I’ve been looking for some more information as to how to use the FlightXML 2 API, but it’s just difficult to find anything. FlightInfoEx is being called: $result2 = $client->FlightInfoEx($flightid,1,0);