Hi Folks,
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
<?php
ob_start();
$user = 'type your User ID number';
$pass = 'type your password';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://{your website}/{phpvms folder}/index.php/api/pilots');
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Authorization: Basic '.base64_encode($user.':'.$pass)));
curl_exec($ch);
$result = ob_get_contents();
ob_end_clean();
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
header("Content-Type: text/html;
charset=utf8");
echo "$httpCode<br>$result";
I hope I've helped!👍