More than 15 results?


#1

I’m building a web app with flight data and need to get a bunch of flight statuses all at once, then store and use them on sql on my server. Does anyone know if there’s anyway to get more than 15 results from DirectFlight? It will speed up my app considerably…

Thanks in advance…
Marc


#2

Make multiple queries with the offset argument. More information is available in the documentation.


#3

I’m using this command for my test run (straight from the sample PHP code):
$result = $soap->Enroute(‘KORD’,10000,‘airline’,0);

How would I make multiple queries with the offset argument? The documentation did not give sample code snippets to compare against.

Thanks again,
Marc


#4

Request:
$result = $soap->Enroute(‘KORD’,15,‘airline’,0);
And the first item in the result (before the array of enroute structs) will be an int for the next_offset to use. Then request:
$result = $soap->Enroute(‘KORD’,15,‘airline’,next_offset);
Where next_offset is the value that was returned to you in the previous query. Wash, rinse, and repeat until you have all the results you want or get a next_offset of -1, which means no more results are available.


#5

Thanks for the quick response! Am I right that these:
$result = $soap->Enroute(‘KORD’,15,‘airline’,0);
$result = $soap->Enroute(‘KORD’,15,‘airline’,next_offset);

Equal 2 queries that I’ll be charged for? The reason I ask is so I know how much to expect to be charged based on my subscription to FlightAware…

Thanks again!
Marc


#6

Yes, each call to $soap->Enroute() will be charged as a query.
Currently there are 170 flights on the enroute board for KORD, so it would take 12 queries to get all of them.


#7

I really appreciate all the help you’re giving. One additional question… is there a way to quickly separate this data out in PHP? I know how to print the data out of the array, but I’m wondering if there’s a way to get the same data formatted in XML? I can separate that out really quickly and easily. I’ve seen a lot of samples of it on the site, but I don’t see a quick sample for a way to get the same data in XML.

Your help is greatly appreciated!
Marc


#8

When you pass “next_offset,” it needs to be the variable that DirectFlight sends you (an integer), not the literal string “next_offset”

I’m not sure what you mean about XML. The data is coming across in XML and SOAP is turning it into arrays for you, so it’s already separated out, so to speak.


#9

So when I use this code:
$result = $soap->Enroute(‘KORD’,15,‘airline’,next_offset);

How do I tell it in PHP to use the next_offset value? How can I reference the value that FlightAware passes back to me?

Marc