Below is an example of Basic API authentication for the admin user (note the -u ‘admin’:’blurred password’):
However, the recommended authentication mechanism for the admin user on Wildix systems running WMS 5 or higher is S2S authentication using the PHP HTTP client library. In this article, we will see in detail how to use this authentication mechanism for API requests.
Every request made to WMS API needs to have the following headers:
Host - domain to which the API request is sent
Authorization - contains the JWT token with the necessary data and signature
X-APP-ID - API ID obtained from WMS or API
You can find the documentation regarding the Authentication mechanism in your system (logged in as admin): https://SYSTEM-NAME.wildixin.com/api/v1/doc/#section/Authentication.
However, to simplify your development, there is Wildix php library that you can use which handles all the process for authentication. Besides the mentioned php library, a tool for dependency management in php called composer will also be used here. Neither s2s-client-php nor composer are mandatory when trying to use Wildix API, but here they are used to show a basic working example. In a php environment they make it easier to consume Wildix APIs but any language/ environment that can implement JWT tokens can be used for your development.
1. A server with apache2 and php installed is assumed. First, install required dependencies:
3. Next move composer to /usr/bin folder to make it available system wide:
$sudo mv composer.phar /usr/bin/composer
4. Now proceed to installing the s2s-client-php library. Get the library from git (https://github.com/Wildix/s2s-client-php). You can do this by either cloning the project or downloading the zip file. For simplicity here, we download the zip file:
7. Next, run the following command (from your project folder):
$sudo composer require wildix/s2s-client-php
After running the command above you should have a composer.json file and a vendor folder inside your project folder as shown below:
Once you have both the json file and the vendor folder you can use the library on your scripts.
Note: if the following error message appears in the previous step: The "https://repo.packagist.org/packages.json" file could not be downloaded: failed to open stream: Connection timed out, use a work around described below.
You can use a work around. Simply create an entry (as root) in your hosts file for the domain name and ip address:
In the previous picture, first we create variables for the needed parameters. In the example we get only id,start,end,src,dst with fields variable, and filter calls for 02/06/2020 with filter array. Then we refer to those variables in the params section (for GET requests params section is used). It is worth mentioning that all parameters need to be ordered alphabetically and the parameter names can only be lowercase.
3. Finally we just need to make the request and get the response:
In the previous picture, first we create variables for the needed parameters. In this example we will use Kimberly voice to create a file named testfromAPI that will be stored in the sounds root directory. Then we will refer to those variables in body section (for POST requests body section is used). It is worth mentioning that all parameters need to be ordered alphabetically and parameter names can only be lowercase.
Finally we just need to make the request using post method and get the response:
In the previous picture, first we create variables for needed parameters. In this example we will call extension 108. If extension 108 picks up the call we will dial the number 16144841500). Then we refer to those variables in the body section (for POST requests body section is used). It is worth mentioning that all parameters need to be ordered alphabetically and parameter names can only be lowercase.
Finally we just need to make the request and get the response: