Skip to content

BasicAuth

Gorka Guerrero edited this page Jun 15, 2018 · 3 revisions

The BasicAuth class will allow the developer perform a connection with the API via username and password in order to interact with it later.

We can declare this class by executing the following PHP code

$apiAuth = new CapqiAuth();
$auth    = $apiAuth->newAuth(array('email'=> EMAIL, 'password'=> PASSWORD), 'BasicAuth');

The $auth object will be needed later for the interaction with the endpoints. If there is no errors, after executing the previous code, we will have the object $employers and access to the following functions:

Next, we will explain in detail each of the functions, the parameters accepted and the data returned when executed.

getApiLang()

Description

This function returns the language the texts are written in, in the API

Parameter(s)

No parameters needed

Execution

$auth->getApiLang();

Response

String

In the examples page you can check how this function is executed with some code snippet


getApiNewReviewUrl()

Description

This function returns the URL that can be use for redirecting to new reviews

Parameter(s)

No parameters needed

Execution

$auth->getApiNewReviewUrl();

Response

//URL that can be use for the users
String

In the examples page you can check how this function is executed with some code snippet


getApiMail()

Description

This function returns the email of the user logged in in the API via this library

Parameter(s)

No parameters needed

Execution

$auth->getApiMail();

Response

//The email used for log in
String

In the examples page you can check how this function is executed with some code snippet


getApiPartnerId()

Description

This function returns the Partner ID of the user logged in in the API via this library

Parameter(s)

No parameters needed

Execution

$auth->getApiPartnerId();

Response

//The Partner ID of the user logged in
String

In the examples page you can check how this function is executed with some code snippet


getApiToken()

Description

This function returns the token if the authentication is correct

Parameter(s)

No parameters needed

Execution

$auth->getApiToken();

Response

//The token if the authentication is correct
String

In the examples page you can check how this function is executed with some code snippet


getApiUrl()

Description

This function returns the URL of the API

Parameter(s)

No parameters needed

Execution

$auth->getApiUrl();

Response

//The URL of the API
String

In the examples page you can check how this function is executed with some code snippet


initialize()

Description

This function initializes the class.

Parameter(s)

Key Type Description
email* String The email of the account used for the log in
password* String The password of the account used for the log in
lang String (default: 'en') The language we want the texts from the API
url* String The URL where the API is
access_token String (default: NULL) The token (if we already have) from a previous authentication

Parameter with * is mandatory. Otherwise, you can omit it and the default value will be used

Execution

//The function is not called directly. It has to be initialized from the declaration of the Auth class
$apiAuth = new CapqiAuth();
$auth    = $apiAuth->newAuth(array('email'=> EMAIL, 'password'=> PASSWORD), 'BasicAuth');

In the examples page you can check how this function is executed with some code snippet


isValidAuth()

Description

This function returns the URL of the API

Parameter(s)

No parameters needed

Execution

$auth->isValidAuth();

Response

//True or False if the data is valid and the authentication has been established
Bool

In the examples page you can check how this function is executed with some code snippet In the examples page there is code available for this function

Clone this wiki locally