GET Phone Numbers API


Getting valid phone numbers or CDRs (Call Detailed Records) to dial is a time consuming task that many of us waste time on in the Telecom industry specially Network Operation Team in VoIP companies or wholesale departments as well as call centers that are trying to find good numbers to dial, TelecomsXChange makes it easy to retrieve numbers via a single API call and a JSON response.


We have made an API for getting valid phone numbers from our backend database for simplifying this task.

Features:


- Get valid phone numbers to any country in the world

- Set a limit in the API call to how many numbers to get in the response

- Get Country name, Code, Description in response

- Get only good numbers that had at least 2 Minutes + in duration before.

- Random Numbers on every API call to avoid duplicates

- Max 1000 Phone numbers per request.


Use cases:


- Pull valid test numbers to any country in split second,

- Get phone numbers to international countries


Roadmap:


- Specify FROM & TO dates in your API Call

- Specify successful Durations in your API call


Requirements:


- PHP 5.1 or higher

- PHP Curl Module (php-curl)

- TelecomsXChange Buyer Account ( You can signup for one here www.telecomsxchange.com/buyerjoin )



Sample code for the Get_numbers API:


<?php

//TelecomsXChaneg USER ID
$api_login ="ENTER YOUR BUYER USERNAME";

//API key

$api_key = 'ENTER API KEY HERE';

// initialising CURL
$ch = curl_init();

//controller is a script name, so in case lookup.php controller is lookup
$controller = "get_numbers";

//unix timestamp to ensure that signature will be valid temporary
$ts = time();

//compose signature concatenating controller api_key api_login and unix timestamp
$signature = hash( 'sha256', $controller .  $api_key   . $api_login  . $ts);

$params = array(
                'ts' => $ts,  //provide TS
                'signature' => $signature,
                'api_login' => $api_login,
                'webapi'    => 1,
                'limit'     => "10",
                'prefix'    => "1954"

                );


//query against api. URL
curl_setopt($ch, CURLOPT_URL,"https://members.telecomsxchange.com/$controller.php");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,
http_build_query($params));



curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$server_output = curl_exec ($ch);
curl_close ($ch);

//analyze JSON output
echo "server_output:$server_output";



Successful Response:


  • CLD = Phone number (This is valid number you can dial)
  • Billing Prefix =  The country code



"status": "success",
    "cdrs": [
        {
            "CLD": "1954640000",
            "billing_prefix": "1",
            "country_code": "us",
            "country_name": "United States Of America",
            "description": "Florida"
        },
        {
            "CLD": "19548710000",
            "billing_prefix": "1",
            "country_code": "us",
            "country_name": "United States Of America",
            "description": "Florida"
        },
        {
            "CLD": "19542610000",
            "billing_prefix": "1",
            "country_code": "us",
            "country_name": "United States Of America",
            "description": "Florida"
        },
        {
            "CLD": "19545560000",
            "billing_prefix": "1",
            "country_code": "us",
            "country_name": "United States Of America",
            "description": "Florida"
        },
        {
            "CLD": "1954610000",
            "billing_prefix": "1",
            "country_code": "us",
            "country_name": "United States Of America",
            "description": "Florida"
        }
    ]


Incase of error you will get:


Response:


server_output:{
    "status": "error",
    "message": "Limit less than 1000 expected"
}