Closed tuxxy132 closed 2 years ago
It really should start with no issues. Try to 1. wait for everything to load and then do a refresh on the page again. There were a couple of instances I had to do that. 2. Try to input the API string directly on your browser address bar and confirm that you are getting a good reply from the API (the request string looks like this: https://airlabs.co/api/v9/schedules?dep_iata=MIA&api_key=YOUR_API_KEY).
I'm also facing the same issue with Apache2 web server. Confirmed that my API key works with your given link too.
Noted for the correct reply from the APi when you use the request directly. I also used Apache2, so there should be no issues there. I assume your pi/ computer running this is inside your home network. Try to connect to it from another computer on the same network by going to http://you_internal_ip/base.php. Does anything show up on the list?
I in fact ssh to my pi to begin with, so I always use an external PC from the start and yet still nothing shows up on the board... I only put in my API key, and suspected nothing else should be required for it to work.
When you do ctrl-shift-i on your browser what do you see as an error on the network tab? Do a shift-F5 refresh
Hello,
Same issue here.
API is working fine.
Inspect Console shows me :
Failed to load resource: the server responded with a status of 500 (Internal Server Error) when loading api.php
If I ran api.php I get "Array".
Error log shows:
2022-07-24 10:48:29: (mod_fastcgi.c.421) FastCGI-stderr: PHP Notice: Array to string conversion in /var/www/html/board/api.php on line 18 2022-07-24 10:48:29: (mod_fastcgi.c.421) FastCGI-stderr: PHP Fatal error: Uncaught Error: Call to undefined function curl_init() in /var/www/ht$ 2022-07-24 10:48:29: (mod_fastcgi.c.421) FastCGI-stderr: Stack trace: 2022-07-24 10:48:29: (mod_fastcgi.c.421) FastCGI-stderr: #0 /var/www/html/board/api.php(24): apiCall('https://airlabs...', 'schedules', Array) 2022-07-24 10:48:29: (mod_fastcgi.c.421) FastCGI-stderr: #1 {main} 2022-07-24 10:48:29: (mod_fastcgi.c.421) FastCGI-stderr: thrown in /var/www/html/board/api.php on line 91
Any idea ?
Tks
oh, I think you need to install php-curl. See the accepted answer here: https://stackoverflow.com/questions/6382539/call-to-undefined-function-curl-init
That did it! Thank you very much for your help :)
@ftonioli Did that also worked for you? Can I close this issue?
@ftonioli Did that also worked for you? Can I close this issue?
No, Installed, the 500 error disapear, but still not getting any data.
2022-07-24 10:58:16: (mod_fastcgi.c.421) FastCGI-stderr: PHP Notice: Array to string conversion in /var/www/html/board/api.php on line 18
Now, if I run api.php alone, I get some data
Array{"error":false,"airport":"Lisbon","utc_offset":1,"arrivals":[{"arr_time":"08:00","carrier_logo":"https:\/\/airlabs.co\/img\/airline\/s\/AD.png","flight_iata":"AD875","origin":"","status":"landed"}],"departures":[{"dep_time":"10:05","carrier_logo":"https:\/\/airlabs.co\/img\/airline\/s\/A3.png","flight_iata":"A3173","destination":"London","status":"BRDING CLSED"}]}
Array{"error":false,"airport":"Porto","utc_offset":1,"arrivals":[{"arr_time":"09:45","carrier_logo":"https:\/\/airlabs.co\/img\/airline\/s\/AC.png","flight_iata":"AC407","origin":"Newark","status":"landed"}],"departures":[{"dep_time":"10:10","carrier_logo":"https:\/\/airlabs.co\/img\/airline\/s\/FR.png","flight_iata":"FR727","destination":"Vienna","status":"BRDING CLSED"}]}
Hmmm, getting that when calling api.php directly, means that the API call is succesful. It's something to do with the display of data. What is your environemnt? Apache2, php8, linux?
Hmmm, getting that when calling api.php directly, means that the API call is succesful. It's something to do with the display of data. What is your environemnt? Apache2, php8, linux?
Lighttpd with PHP 7.3, running in a Raspberry PI 4 with Linux piaware 5.10.103-v7l+
I don't have any experience with lighttpd. One thing to look at though is that line 18 is a comment, there is no code there. Can you confirm your line 18 is the same as the code on the repository?
2022-07-24 10:58:16: (mod_fastcgi.c.421) FastCGI-stderr: PHP Notice: Array to string conversion in /var/www/html/board/api.php on line 18
OKOK, this was my fault.
I had inserted an "echo $icao_code" to figureout if it was getting airport code, and left it after install php-curl.
Now is working, but:
Local time and Porto time should be the same, whats wrong ?
@commacmms, This is pretty cool!!!
The only thing, is that shows more "landaded" than estimated. How to limit the "Landed" flight to show more Estimated ?
Test $arrivals_results["response"][$i]["status"]
inside the for loop that starts on line 40 of api.php if it is == "LANDED"
, do not add it to $data['arrivals'][$i]['status']
. But this has an issue because you will get less results on the table than you specified, so you have to extract more results than you want to show on the table - this is all very possible but requires a bit of work, I'm not going into that now.
The other possible option that could simplify things is to send the start time and the end time of the request to the API schedule endpoint. I don't know if that is possible, you need to read the API documentation for the schedules endpoint. In case that is possible, you need to add the parameters to the current ones
$params["arr_icao"] = $icao_code;
$params["api_key"] = $api_key;
$params["start_time"] = xxxxx; //Not sure if this is possible, read API docs
$params["end_time"] = xxxx; //Not sure if this is possible, read API docs
We are digressing from the original issue. I will close this now.
Hi Commacmms love the project and idea. I added my api key to the ( api file and test with https://airlabs.co/api/v9/schedules?arr_icao=EGCC&api_key=mykey ) I also added ( <input type="hidden" id="num_of_rows" value="10"<?php echo $num_of_rows;?>"> ) to the base file but still no joy am i missing somethink, any advise would be great.