API Authentication

Install and configure FormaLMS and DoceboCE
Post Reply
Rival
Newbie
Posts: 5
Joined: Wed Apr 24, 2019 2:33 pm

API Authentication

Post by Rival »

Hi,

Let me start by saying I can just about read PHP code. I got somebody to write some PHP code for formaLMS's API. (This person is no longer available to help me.) :cry:

For the most part, the code is working beautifully. I do however need help securing this with a token. Can somebody explain how to modify the below code and how to set it up in the LMS's API Authentication method?

I did read the new API documentation but I can't figure it out.
Here is the code I got. Any help would be greatly appreciated.

Code: Select all

<?php

$url = "https://demo.formalms.com:443/";
$action = 'user/updateuser';

$data_params = array('idst' => 11836, 'lastname' => 'Doe');
						   
                 $curl = curl_init();

                 $opt = array(
                         CURLOPT_URL=>$url.'/api/'.$action,
                         CURLOPT_RETURNTRANSFER=>1,
                         CURLOPT_POST=>1,
                         CURLOPT_POSTFIELDS=>$data_params,
                         CURLOPT_CONNECTTIMEOUT=>5, // Timeout to 5 seconds
                         CURLOPT_SSL_VERIFYPEER => 'false',
                         );

                 curl_setopt_array($curl, $opt);

// $output contains the output string

                 $output = curl_exec($curl);

// it closes the session

                 curl_close($curl);

                 echo $output;
alfa24
Senior Boarder
Posts: 1982
Joined: Fri Nov 24, 2017 8:45 am

Re: API Authentication

Post by alfa24 »

What kind of token?
Can you be more specific?
Per supporto GRATUITO contattatemi in privato qui
Rival
Newbie
Posts: 5
Joined: Wed Apr 24, 2019 2:33 pm

Re: API Authentication

Post by Rival »

Hi,

I am not sure what token/setup to use to make the API more secure. In the LMS under API settings you can specify "Token generation at every connection" or "Authorisation Secret Key". Or should I specify a random string in the textbox? But then how do I reference this string in the API code. Like I said I am not sure how to secure the API interface so that not every Tom Dick and Harry can use the API once enabled.

Image
alfa24
Senior Boarder
Posts: 1982
Joined: Fri Nov 24, 2017 8:45 am

Re: API Authentication

Post by alfa24 »

So you only need the API work with the provided token. If you can't find it out with the docs, feel free to write me privately and I'll help to develop your own API layer.
Per supporto GRATUITO contattatemi in privato qui
Post Reply