A basic REST API module for access to phpVMS data and functionality, for example in third party clients & other sites.
Note : This is very much still in development. It isn’t very thoroughly tested or remotely complete in functionality, however it is a start and I’m putting it up to allow others to contribute and speed up development. Use with caution.
Current Features:
Username/password user auth for all requests via Basic Auth
Only available to confirmed registered users
Removes sensitive information from responses (encrypted password, salt, emails, IP addresses)
All PUT/POST data is expected to be JSON
Get paginated news list (requires SimpleNews)
Get individual news item (requires SimpleNews)
Get pilot list
Get individual pilot details
Get details of current user (of the API)
Get schedule list
Get individual schedule
Bid on a schedule
Approve/Reject registrations (Admin)
Obviously there’s a lot left to do so I welcome contributions. You can find the code & more detailed information on GitHub.
If you have any issues please open them on GitHub rather than a forum post here.
The endpoints are documented in the readme on GitHub - they’re mostly GET requests so very simple. How you make those GET requests depends on what you’re doing (i.e. from Javascript, or an app, etc.) but you can find tons of tutorials on making HTTP requests online.
In its current state the API requires basic auth user credentials set in the Authorization header for every request. Also unless you’ve set up URL redirects you’ll need to access it via “site.com/action.php/api/…”
You can show an example of an authorization code that must be on the pages?
You’ll need to add the header “Authorization” with the value “Basic dXNlcm5hbWU6cGFzc3dvcmQ=”, where dXNlcm5hbWU6cGFzc3dvcmQ= is base64_encode($username.‘:’.$password)
There’s a file called core/modules/api/api.php. Inside that file, there’s a function called “private static function setup()”. Comment the line 81(self::checkUser() and you’ll be able to use this API without Verification. Sorry for my english.
This definitely doesn’t work for me. Unless I delete line 81 as presented above by #JefferssonSantos, even using Authorization Basic
On 12/3/2020 at 11:53 PM, JefferssonSantos said:
There’s a file called core/modules/api/api.php. Inside that file, there’s a function called “private static function setup()”. Comment the line 81(self::checkUser() and you’ll be able to use this API without Verification. Sorry for my english.
So, I scanned the PHP code and got the result. Let´s go!
You can do a quick test using Postman. If you don’t have it yet, download it here: https://www.postman.com/downloads/
You need to create an account and password to use it, it’s free!
See the attached print of my postman that will guide the explanation.
Define the method, in this case GET, as I want to bring the list of pilots.
Enter your URL remembering to put the folder where your phpVMS is installed.
Click Authorization tab
Choose the type of authorization, in this case Basic Auth
Enter your username. This is where I was wrong and it’s not clear from the API documentation. Your username is your ID and not your callsign used when you log into phpVMS. So, ID is the number (unless zeros) that after airline code. Example: My login callsign is XYZ0001, so my username is 1.
Type your password
Finally, I got a positive response!
Here’s an example of the PHP code you can make inside your phpVMS using cURL