- Php v8
- Composer
- Slim packages
- slim/slim : ^4.8
- slim/http : ^1.2
- slim/psr7 : ^1.4
Assuming your adserver is place at
/var/www/html/adserver
location. Below instructions are based on the adserver location. It can be different but make sure to configure adserver according to your requirements.
Step 1:
Dowload the rest api source code and copy rest
dir inside the adserver's <adserver-dir-name>/www/api/v2/rest
directory
Step 2:
Go to the adserver's directory and install below packages
$ composer require slim/slim
$ composer require slim/http
$ composer require slim/psr7
Step 3:
Configure nginx server
location ~ ^/var/www/html/<adserver-dir-name>/(?!$|www/) {
return 403;
}
//to access rest apis
location /<adserver-dir-name>/www/api/v2/rest/ {
try_files $uri $uri/ /<adserver-dir-name>/www/api/v2/rest/index.php?$args;
}
Make this request to verify installation
Heartbeat Request
curl --location --request GET 'http://<host-name>/adserver/www/api/v2/rest'
Heartbeat Response
{
"status": "UP"
}
This API is required before calling and other API request. This API will return sessionID
and use header sessionID: <session-id>
Login Request
curl --location --request POST 'http://<host-name>/adserver/www/api/v2/rest/login' \
--header 'Content-Type: application/json' \
--data-raw '{
"username": "<admin-username>",
"password": "<admin-password>"
}'
Login Response
{
"message": "Login",
"data": {
"username": "<admin-username>",
"sessionID": "<session-id>",
"created_at": 1719471784
},
"timestamp": 1719471784
}
Base URL: http|https://<host-name>/<adserver-dir-name>/www/api/v2/rest
Default Base Path /adserver/www/api/v2/rest
if root
variable value in nginx.conf server block is set to /var/www/html/adserver
then Base path will be /www/api/v2/rest
and make sure follow below instructions.
Configure any once approach either 1 or 2
- Edit conf file located at path
<adserver-dir-name>/var/<host-name>.conf.php
- Under
[webpath]
add conf propertyrestAPI="<path-for-rest-api>"
and save it.
This approach override the above if conf property is not present
- Edit file
<adserver-dir-name>/www/api/v2/rest/index.php
- Update path here
define('API_BASE_PATH', '/adserver/www/api/v2/rest')
and save it.
- Create plugin for Rest API for easy of use and configuration.