How to Install the PHP Snippet

Updated 7 months ago

To integrate the phone number pool, you need to connect the PHP script file dialics_get_pool_number.php. This file contains the code that allows you to get an available number from the pool of numbers.To include this file on your landing page, you need to add the following construct:include_once 'dialics_get_pool_number.php';Next, you need to set the variables:

$number = $_GET['number']; // Get the default number from the URL in case the code cannot get a number from the pool; you should have a tag number=<default number>$dialics_number = '';$token = $_GET['dc']; // Set the token for obtaining the number; you can get it from the campaign

After that, you need to call the function that will make a request to the Dialics server to get the phone number:

$dialics_number = dialics_get_pool_number($token);

The variable `$dialics_number` will contain the phone number as a string. You can format this string into any desired format. For example, you may receive the following number:

$dialics_number = ‘33955663322’;

Each digit in this number has its index starting from 0. So, the first digit '3' will have index 0, and the last digit '2' will have index 10.

By using the following construct:

$phone_number = "0" . $dialics_number[2] . "-" . $dialics_number[3] . $dialics_number[4] . "-" . $dialics_number[5] . $dialics_number[6] . "-" . $dialics_number[7] . $dialics_number[8] . "-" . $dialics_number[9] . $dialics_number[10];

You will get the following number:

09-55-66-33-22

Next, you need to perform a test. If it fails to get a number, you need to substitute the default number.

if (empty($dialics_number)) { $phone_number = $number;}

Below is the complete code (for FR numbers):

<?phpinclude_once 'dialics_get_pool_number.php';$number = $_GET['number']; // Get the default number from the URL in case the code cannot get a number from the pool; you should have a tag number=<default number>$dialics_number = '';$token = $_GET['dc']; // Set the token for obtaining the number; you can get it from the campaign$phone_number = ''; //This variable will contain the phone number to be placed in the landing codeif(isset($token) && !empty($token)) { $dialics_number = dialics_get_pool_number($token); $phone_number = "0" . $dialics_number[2] . "-" . $dialics_number[3] . $dialics_number[4] . "-" . $dialics_number[5] . $dialics_number[6] . "-" . $dialics_number[7] . $dialics_number[8] . "-" . $dialics_number[9] . $dialics_number[10];}if (empty($dialics_number)) { $phone_number = $number;}//This code is necessary for passing URL parameters during the redirect to the directory$parsed = parse_url($_SERVER['QUERY_STRING'])$query = $parsed['path'];parse_str($query, $params)unset($params['number']);$string = http_build_query($params);?>

Table of contents

Was this article helpful?