-
Notifications
You must be signed in to change notification settings - Fork 0
BasicAuth
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:
- getApiLang()
- getApiNewReviewUrl()
- getApiMail()
- getApiPartnerId()
- getApiToken()
- getApiUrl()
- initialize()
- isValidAuth()
Next, we will explain in detail each of the functions, the parameters accepted and the data returned when executed.
This function returns the language the texts are written in, in the API
No parameters needed
$auth->getApiLang();StringIn the examples page you can check how this function is executed with some code snippet
This function returns the URL that can be use for redirecting to new reviews
No parameters needed
$auth->getApiNewReviewUrl();//URL that can be use for the users
StringIn the examples page you can check how this function is executed with some code snippet
This function returns the email of the user logged in in the API via this library
No parameters needed
$auth->getApiMail();//The email used for log in
StringIn the examples page you can check how this function is executed with some code snippet
This function returns the Partner ID of the user logged in in the API via this library
No parameters needed
$auth->getApiPartnerId();//The Partner ID of the user logged in
StringIn the examples page you can check how this function is executed with some code snippet
This function returns the token if the authentication is correct
No parameters needed
$auth->getApiToken();//The token if the authentication is correct
StringIn the examples page you can check how this function is executed with some code snippet
This function returns the URL of the API
No parameters needed
$auth->getApiUrl();//The URL of the API
StringIn the examples page you can check how this function is executed with some code snippet
This function initializes the class.
| 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
//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
This function returns the URL of the API
No parameters needed
$auth->isValidAuth();//True or False if the data is valid and the authentication has been established
BoolIn 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