Tom Posted January 24, 2015 Report Posted January 24, 2015 phpVMS REST API 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. https://github.com/t...phpVMS-REST-API Quote
Moderators ProSkyDesign Posted February 5, 2017 Moderators Report Posted February 5, 2017 any tutorial :(? Quote
Tom Posted February 9, 2017 Author Report Posted February 9, 2017 On 05/02/2017 at 3:45 AM, joooseb said: any tutorial :(? 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. Quote
Tom Posted February 15, 2017 Author Report Posted February 15, 2017 5 hours ago, bass said: Hi, trying to get the data from database through your module, but I can't. Make a request like this: my.site.ru/index.php/api/pilots not working my.site.ru/api/pilots not working 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/..." Quote
Tom Posted February 16, 2017 Author Report Posted February 16, 2017 @bass Can you give any more information than "does not work"? What response do you get? Don't forget to set the 'Authorization' header. Quote
Tom Posted February 18, 2017 Author Report Posted February 18, 2017 22 hours ago, bass said: The answer I have just the number "1" 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) Quote
Moderators ProSkyDesign Posted March 27, 2017 Moderators Report Posted March 27, 2017 21 hours ago, bass said: Reviewed a lot of information, but was not able to get this module to work(((Is there someone who have this module working? the best way I find to display pilot page is an iframe without layout Quote
Moderators ProSkyDesign Posted March 28, 2017 Moderators Report Posted March 28, 2017 (edited) 9 hours ago, bass said: /action.php/pilots ??? It does not suit me( No, make a copy of the folder of your phpvms in your cpanel with other name.. For example "content" and then go to layout.tpl and delete all skins css or script. Late make a page with your content that you want to display, and then call it via iframe to your site =). <html> <head> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1"> </head> <style type="text/css"> #test iframe { width: 100%; height: 100%; border: none; } #test { width: 100%; height: 650px; padding: 0; overflow: hidden; } </style> <body style="margin:0;"> <div id="test"> <iframe src="http://www.yoursite.com/index.php" scrolling="no"> </iframe> </div> </body> </html> That's I did in my wordpress site: www.travelskyalliance.com Edited March 28, 2017 by joooseb Quote
brenohff Posted August 7, 2017 Report Posted August 7, 2017 Can someone help me with REST API? I put the files inside /core folder and I don't know what I have to do now.... Quote
Tom Posted August 7, 2017 Author Report Posted August 7, 2017 2 hours ago, brenohff said: Can someone help me with REST API? I put the files inside /core folder and I don't know what I have to do now.... You make calls to the API endpoints. I've fixed the readme, seems GitHub changed how they parse markdown and broke it Make sure you're including a Basic Auth token on all requests. Quote
brenohff Posted August 7, 2017 Report Posted August 7, 2017 31 minutes ago, Tom said: You make calls to the API endpoints. I've fixed the readme, seems GitHub changed how they parse markdown and broke it Make sure you're including a Basic Auth token on all requests. I did the installation as you said in github but when i make a GET request, the response came empty... I'm putting Authorization: Basic YnJlbm9oZmZAZ21haWwuY29tOmIyMjA1OTZi at header Quote
brenohff Posted August 7, 2017 Report Posted August 7, 2017 5 hours ago, Tom said: You make calls to the API endpoints. I've fixed the readme, seems GitHub changed how they parse markdown and broke it Make sure you're including a Basic Auth token on all requests. Now I'm getting error 401 Unauthorized even adding the authorization header = / Quote
brenohff Posted May 11, 2020 Report Posted May 11, 2020 @Mamoth112, how are you sending the auth header? Quote
JefferssonSantos Posted December 4, 2020 Report Posted December 4, 2020 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. Quote
Nascoli Posted December 14, 2021 Report Posted December 14, 2021 Tom is there? 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. Quote
Nascoli Posted December 14, 2021 Report Posted December 14, 2021 (edited) 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!👍 Edited December 14, 2021 by Nascoli Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.