POSTS
PORTFOLIO
SEARCH
SHOP
  • Your Cart Is Empty!
Your address will show here +12 34 56 78
API command for developers
Looking for telecom solutions without needing a developer? Our user portal has you covered! 
  • Text Hover
Generate Call Reports
In your php file, you will run the command callHistory().
The function takes five parameters
    trunk(string): the trunk name.
    period(int):0 (default) - current hour 
        1 - previous hour
        2 - current day
        3 - previous day
   An array - start / end ('2018-04-25 21:00:00','2018-04-25 22:24:58)
   Type(int): inbound or outbound
        0 - all calls
        1 - inbound calls
        2 - outbound calls
   Attempts(string): show unsuccessful records
        no(default) - show only successful calls
        yes - show successful calls
  DID(string | array): narrow by DID
        string - any DID enclosed in " " ("XXXXXXXXXX")
        array - an array of DIDs
  Call Summary (string): can be either "yes" or "no". Returning "yes" will return the total of dialed seconds of all calls instead of a detailed report.

Over 2000 records will throw an error "too many records". This feature can slow down the PBX if abused. Decide the best time interval for your CDR reporting and call times.
You will not see anything in your log if you do not print the results to console
EXAMPLE:
<?php
$api = new QBapi();
$period = array("2018-01-01 21:00:00","2018-06-06 15:00:00");
$result = $api->callHistory("trunkName",$period,0,"yes","1XXXXXXXXXX", "no");
echo '<pre>';
print_r($result);
?>
Will return (for example):
[372] => SimpleXMLElement Object
(
[call_time] => 18/01/11 19:56:27
[did_from] => 1XXXXXXXXXX
[did_to] => 1XXXXXXXXXX
[call_status] => ok
[call_type] => Inbound Toll Free Call
[rate] => 0.019
[duration] => 16.610
[cost] => 0.023
)
Finding DID's and Rate Centers
For Advanced Sorting Options 

There are several commands that assist with this in the API. listStates() will simply list the states with readily available numbers. listRateCenters() takes in two parameters:
State Code(string): the two character code from listStates()
Tier(integer):
        1 - default
        1b
        2
If you refer to the API documentation, you will see that these two functions, and the following function, can all be used together.
EXAMPLE:
<?php
$api = new QBapi();
$result = $api->listRateCenters($api->listStates()->states[13], 1);
?>
The function listAvailableLocalDIDs() takes 4 parameters.
    Rate Center(string): name of the center. ex: ADAMS
    State Code(string): two letter code. ex: Alabama = AL
    NPA(string or int): Numbering Plan area codes. You have two options, use the first two parameters, or use the NPA parameter.
     NPA: listAvailableLocalDIDs(null,null,202,X);
          Where null is entered null and X represents the last parameter
     Center and State Code: listAvailableLocalDIDs("ADAMS","MA",null,X);
   Tier(int): the DID tier. 1, 1b, or 2. If tier value 2 is sent then the results will include DIDs that may not support SMS.
EXAMPLE:
<?php
$api = new QBapi();
$result = $api->listAvailableLocalDIDs(null,null,919,2);
echo '<pre>'
print_r($result);
?>
Will Output
[result] => success
[dids] => Array
(
[0] => XXXXXXXXXX
[1] => XXXXXXXXXX
[2] => XXXXXXXXXX
...
[58] =>XXXXXXXXXX
Our API enables you to narrow your search down when calling the function by chaining the searches together.
EXAMPLE:
<?php
$api = new QBapi();
$result = $api->listAvailableLocalDIDs( $api->listRateCenters($api->listStates()->states[10], 1)->ratecenters[13], $api->listStates()->states[10],null,1);
echo '<pre>';
print_r($result);
?>
Will Output
[result] => success
[dids] => Array
(
[0] => XXXXXXXXXX
[1] => XXXXXXXXXX
[2] => XXXXXXXXXX
...
[100] =>XXXXXXXXXX
Finding Toll Free Numbers
The function for returning an array of toll free numbers is similar to listAvailableLocalDIDs().
listAvailableTfDIDs() takes two parameters:
   Tier(int or string): 1 or "1b"
   Prefix: "80", "84", "85", or "86" to order 800, 844, 855, or 866 numbers respectively.

EXAMPLE:
<?php
$api = new QBapi();
$result = $api->listAvailableTfDIDs("1b", "84");
echo '<pre>';
print_r($result);
?>
Will Output
[result] => success
[dids] => Array
(
[0] => 844XXXXXXX
[1] => 844XXXXXXX
[2] => 844XXXXXXX
...
[29] =>844XXXXXXX
Ordering DIDs, Caller ID, and E911
The orderDID() function is capable of ordering a DID without ever touching the user portal. This command takes three parameters. This command is able to take advantage of listAvailableLocalDIDs() or listAvailableTfDIDs() by running them, and the previous functions that they use to narrow their listings, as the parameters.
    DID(string): the number that you want ordered.
    Tier(int or string): 1, "1b", or 2. Using tier 2 will list DIDs incapable of supporting SMS.
    Note(string): a note for the DID up to 12 characters are allowed.
EXAMPLE:
<?php
$api = new QBapi();
$result = $api->orderDID($api->listAvailableLocalDIDs( $api->listRateCenters($api->listStates()->states[10], 1)->ratecenters[13], $api->listStates()->states[10],null,1)->dids[13], "1b", "a note");
echo '<pre>';
print_r($result);
?>
Will Output
[result] => success
[did] => 561XXXXXXX
Caller ID, or "Cnam" can also be ordered through the API, and set up using a separate command covered later.
<?php
$api = new QBapi();
$result = $api->orderCnam("561XXXXXXX");
echo '<pre>';
print_r($result);
?>
Ordering and configuring e911 is all done with one command. It requires the DID, a name, and a full address. This will all be placed in a dictionary array, the command is looking for those exact identifiers. You will need to replace the information listed with the customer's info. This can also be used to update the customer's e911 information.
<?php
$api = new QBapi();
$params = array("did"=>"561XXXXXXX",
"name"=>"BOB SMITH",
"address"=>"1724 Walnut St",
"unit_type"=>"suite",
"unitnumber"=>"10",
"city"=>"Cary",
"state"=>"NC",
"zip"=>"27511");
$result = $api->orderE911($params);
echo '<pre>';
print_r($result);
?>
Keep in Mind that the unit type and unit number parameters are not necessary. They can be safely left out of this function.
Will Output
[result] => success
DID settings and manipulation
propertyDID() is used to list the properties of any number of DIDs depending on the value passed in. It has three options for the parameter:
Empty: The default value that will return properties for every DID.
propertyDID();
Single Number(string): return the properties of a single number.
propertyDID("561XXXXXXX");
Selected multiple(array): will return properties for the specified numbers.
$numbers = array("561XXXXXXX","562XXXXXXX",...,"600XXXXXXX"); propertyDID($numbers);
EXAMPLE:
<?php
$api = new QBapi();
$params = array("919XXXXXXX","561XXXXXXX");
$result = $api->propertyDID($params);
echo '<pre>';
print_r($result);
?>
Will Output
[did] => 561XXXXXXX
[type] => local
[note] => a note
[cnam] => yes
[lidb] => no
[e911] => yes
[e911_name] => BOB SMITH
[e911_address] => 1724 Walnut St
[e911_unit] => 10
[e911_city] => Cary
[e911_state] => NC
[e911_zip] => 27511
[status] => active
[route] => no_route
[forward] => none
[did] => 919XXXXXXX
[type] => local
[note] => none
[cnam] => no
[lidb] => BOBSMITH
[e911] => no
[status] =>
[route] => no_route
[forward] => none
[sms] => disabled

There is a [sms] property that will tell you the status of your DID.
There are 4 possible return values. 
disabled - SMS is not allowed for the DID
email - SMS is forwarded to Email
xmpp - SMS is delivered to XMPP account
both -Email and XMPP.

You can set the DID note with the function setDIDNote(). This takes two parameters:
    DID(string): the number specified
    Note(string): up to 12 characters
<?php
$api = new QBapi();
$result = $api->setDidNote("561XXXXXXX","Oh boya note");
echo '<pre>';
print_r($result);
?>
Setting the text for Cnam is done with the command setLidb() This will show on the phone to callees. This takes two parameters:
    DID(string): the number specified
    Cname(string): up to 15 alphanumeric characters
<?php
$api = new QBapi();
$result = $api->setLidb("561XXXXXXX","Reginald");
echo '<pre>';
print_r($result);
?>
Setting a failover destination for a DID is done using the setDidFailover() function. This functions like setFailoverIp(). It takes two parameters with three values for the second parameter.
    DID(string): the did that is being backed up
    Properties: This can be set to null, no quotes, to unset Fail Over.
    Failover DID(string): a US based failover number, 10 digits only
    Failover Limit(int 1-100): how many calls it needs to trigger
    Failover Time(int 2, 3, 5, 7, 10, 15, 20, 30, 60): the time period that failed calls will add to the limit
EXAMPLE:
<?php
$api = new QBapi();
$params = array("failover_did" => "919XXXXXXX","failover_num"=>"50","failover_time"=>"30");
$result = $api->setDidFaiover("561XXXXXXX",$params);
echo '<pre>';
print_r($result);
?>
To route a DID the routeDID() function will be used. You can select the trunk you would like to use, or unroute the number. Keep in mind that if you are using the API for automated monitoring, and routing your DID's after a failover, you will need to give it some time between removing the forwarding and routing the DID back to the trunk. This takes two parameters:
    DID(string): the did that is being routed
    Trunk(string):
        Empty: this will unroute the DID
        Trunk Name: the trunk the DID will route to
EXAMPLE:
<?php
$api = new QBapi();
//trunkName should be replaced with the name of your trunk in " " $result = $api->routeDID("561XXXXXXX","trunkName");
echo '<pre>';
print_r($result);
?>
Forwarding a DID is a simple task with the forwardDID() function. It needs to have failover set to null, and it must not be on the same account. It needs two parameters:
    Active DID: the DID that will point to the target
    Target DID: A DID that will recieve the call
<?php
$api = new QBapi();
$result = $api->forwardDID("561XXXXXXX","205XXXXXXX"); echo '<pre>';
print_r($result);
?>
Removing DIDs, Cnam, E911
These three operations can all be completed with simple, similar functions. removeDID(), removeCnam(), and removeE911() all take one parameter, the DID they are being applied to.
<?php
$api = new QBapi();
$result = $api->removeCnam(561XXXXXXX);
$result = $api->removeE911(561XXXXXXX);
$result = $api->removeDID(561XXXXXXX);
echo '<pre>';
print_r($result);
?>