Method list
Before starting
1. Get countries
2. Get cities
3. Order DID
4. Build mapping for new DID
5. Change mapping for DID
6. Get region details
7. Get DID details
8. Order autorenew status
10. Cancel DID
11. Cancel Order
Error codes:
* 100 Access denied
* 105 Order already exists
* 106 DID ID: DID_ID NOT found
* 107 Invalid Protocol
* 108 DID: DIDNUMBER NOT found
* 109 DID: DIDNUMBER in Pending/Remove status
* 110 DID: DIDNUMBER NOT renewed
* 111 Invalid status code. Valid codes: 0 - Disable, 1 - Enable
* 113 Order NOT found for DIDNUMBER
* 114 Order already canceled for DIDNUMBER
* 115 ORDER: Cannot cancel not pending order for DIDNUMBER. Please, use did_cancel
* 120 UNIQ: UNIQUEKEY NOT found
* 121 No cities for this country
* 150 Sandbox error. DIDs max limit reached
* 200 Internal Server Error
|
Before starting
a. NuSOAP Extension
In order to use our Web Service, you need to download NuSOAP sources.
The sources can be downloaded from http://sourceforge.net/projects/nusoap/.
The latest version 0.7.1 is stable and we recommend to use this version of NuSOAP classes for API.
b. Authentication Key
You will receive from DID World Wide the authentication key.
Below there are sample codes, how to build authentication string, to pass to methods:
1. This sample is used on reseller's production server for public.
Web Site WSDL URL: http://api.didww.com/api/?wsdl
<?php
$username = 'username@domain.com';
$key = '123456780909';
$auth_string = sha1($username.$key);
2. This sample is used on DID World Wide Sandbox for testing.
Please, note: We are adding word "sandbox" to authentication string
Web Site WSDL URL: http://sandbox.didww.com/api/?wsdl
<?php
$username = 'username@domain.com';
$key = '123456780909';
$auth_string = sha1($username.$key.'sandbox');
|
1. Get countries list
This method will return the list of countries from active coverage list.
|
Method Signature |
<?php
$result = $client->call('getcountries', $auth_string);
?>
string $auth_string
|
Return array: $result |
Array
(
[0] => Array
(
[country_id] => 10
[country_prefix] => 54
[country_name] => Argentina
)
...
|
Code example |
|
<?php
require_once('lib/nusoap.php');
$site = 'http://sandbox.didww.com/api/?wsdl';
$error = 0;
$client = new soapclient($site, true);
$err = $client->getError();
if ($err)
{
echo 'ERROR: <pre>' . $err . '</pre>';
}
$username = 'username@domain.com';
$_key = '1234657890';
$auth_string = sha1($username.$_key."sandbox");
$result = $client->call('getcountries', $auth_string);
if ($client->fault)
{
echo '<pre>';
print_r($result);
echo '</pre>';
}
else
{
$err = $client->getError();
if ($err)
{
echo 'Error: <pre>' . $err . '</pre>';
}
}
echo '<pre>';
print_r($result);
echo '</pre>';
?>
|
Up
2. Get cities list
This method will return the list of available cities by country ID along with reseller's monthly price.
The country ID value is passed from method getcountries
You will need to assign requested 'country_id' from array list to $country_id variable.
|
Method Signature |
<?php
$result = $client->call('getcities', array($auth_string, $country_id)); ?>
string $auth_string
integer $country_id
|
Return array: $result |
Array
(
[0] => Array
(
[uniq] => 10541111
[city_prefix] => 11
[city_name] => Buenos Aires
[monthly] => 4.45
)
...
|
Code example |
|
<?php
require_once('lib/nusoap.php');
$site = 'http://sandbox.didww.com/api/?wsdl';
$client = new soapclient($site, true);
$err = $client->getError();
if ($err)
{
echo 'ERROR: ' . $err . '</pre>';
}
$username = 'username@domain.com';
$_key = '1234657890';
$auth_string = sha1($username.$_key."sandbox");
$arr = array();
$arr[0] = $auth_string;
$arr[1] = $country_id;
$result = $client->call('getcities', $arr);
if ($client->fault)
{
echo '<pre>';
print_r($result);
echo '</pre>';
}
else
{
$err = $client->getError();
if ($err)
{
echo 'Error: <pre>' . $err . '</pre>';
}
}
echo '<pre>';
print_r($result);
echo '</pre>';
?>
|
Up
3. Order DID
This method will make a new order.
The $hashkey value must be different for every new order. If you pass the same hash key again, the Web Service will throw exception.
The 'uniq' variable from method getcities should be assigned to $uniq variable, in order to find DID by this unique key.
This method will return two values, DID ID and DID Number. |
Method Signature |
<?php
$result = $client->call('neworder', array($auth_string,
$hashkey,
$uniq,
$autorenew
$period));
?>
string $auth_string
string $hashkey
string $uniq
integer $autorenew
integer $period
|
Return array: $result |
Array
(
[did_id] => 14
[did_number] => 541152371452
)
|
Code example |
|
<?php
require_once('lib/nusoap.php');
$site = 'http://sandbox.didww.com/api/?wsdl';
$client = new soapclient($site, true);
$err = $client->getError();
if ($err)
{
echo 'ERROR: ' . $err . '</pre>';
}
$username = 'username@domain.com';
$_key = '1234657890';
$auth_string = sha1($username.$_key."sandbox");
$hashkey = md5(mt_rand());
$arr = array();
$arr[0] = $auth_string;
$arr[1] = $hashkey;
$arr[2] = $uniq;
$arr[3] = $autorenew; //0 - disable, 1 - enable
$arr[4] = $period; // Valid values: 1, 3, 6, 12, 24
$result = $client->call('neworder', $arr);
if ($client->fault)
{
echo '<pre>';
print_r($result);
echo '</pre>';
}
else
{
$err = $client->getError();
if ($err)
{
echo 'Error: <pre>' . $err . '</pre>';
}
}
echo '<pre>';
print_r($result);
echo '</pre>';
?>
|
Up
4. Build mapping for DID
This method will build mapping for selected DID ID. The DID ID value is passed from method neworder.
You will need to assign 'did_id' from array list to $did_id variable.
Note: If you want to use the Default mapping, this method should be ignored.
Map Protocols are:
1 - SIP
2 - IAX2
3 - H.323
The default format of URI mapping is PROTOCOL/IPADDRESS.
If you want add DIDNUMBER to URI, please use $add_did = 1. The format will be: PROTOCOL/IPADDRESS/DIDNUMBER
|
Method Signature |
<?php
$result = $client->call('buildmapping', array($auth_string,
$did_id,
$map_proto,
$map_uri,
$add_did));
?>
string $auth_string
integer $did_id
integer $map_proto
string $map_uri
integer $add_did
|
Return integer: $result |
|
|
Code example |
|
<?php
require_once('lib/nusoap.php');
$site = 'http://sandbox.didww.com/api/?wsdl';
$client = new soapclient($site, true);
$err = $client->getError();
if ($err)
{
echo 'ERROR: ' . $err . '</pre>';
}
$username = 'username@domain.com';
$_key = '1234657890';
$auth_string = sha1($username.$_key."sandbox");
$map_proto = 1; // 1 - SIP, 2 - IAX2, 3 - H.323
$map_uri = '444@sip.didww.com';
$did_id = '9090';
$add_did = 0; //Append DID number to URI (0 - no, 1 - yes);
$arr = array();
$arr[0] = $auth_string;
$arr[1] = $did_id;
$arr[2] = $map_proto;
$arr[3] = $map_uri;
$arr[4] = $add_did;
$result = $client->call('buildmapping', $arr);
if ($client->fault)
{
echo '<pre>';
print_r($result);
echo '</pre>';
}
else
{
$err = $client->getError();
if ($err)
{
echo 'Error: <pre>' . $err . '</pre>';
}
}
echo '<pre>';
print_r($result);
echo '</pre>';
?>
|
Up
5. Change mapping for DID
This method will change mapping for selected DID number. The DID number value should be without dashed and white spaces.
Map Protocols are:
1 - SIP
2 - IAX2
3 - H.323
The default format of URI mapping is PROTOCOL/IPADDRESS.
If you want add DIDNUMBER to URI, please use $add_did = 1. The format will be: PROTOCOL/IPADDRESS/DIDNUMBER
|
Method Signature |
<?php
$result = $client->call('change_mapping', array($auth_string,
$did_number,
$map_proto,
$map_uri,
$add_did));
?>
string $auth_string
string $did_number
integer $map_proto
string $map_uri
integer $add_did
|
Return integer: $result |
|
|
Code example |
|
<?php
require_once('lib/nusoap.php');
$site = 'http://sandbox.didww.com/api/?wsdl';
$client = new soapclient($site, true);
$err = $client->getError();
if ($err)
{
echo 'ERROR: ' . $err . '</pre>';
}
$username = 'username@domain.com';
$_key = '1234657890';
$auth_string = sha1($username.$_key."sandbox");
$map_proto = 1; // 1 - SIP, 2 - IAX2, 3 - H.323
$map_uri = '444@sip.didww.com';
$did_number = '1516700100';
$add_did = 0; //Append DID number to URI (0 - no, 1 - yes);
$arr = array();
$arr[0] = $auth_string;
$arr[1] = $did_number;
$arr[2] = $map_proto;
$arr[3] = $map_uri;
$arr[4] = $add_did;
$result = $client->call('change_mapping', $arr);
if ($client->fault)
{
echo '<pre>';
print_r($result);
echo '</pre>';
}
else
{
$err = $client->getError();
if ($err)
{
echo 'Error: <pre>' . $err . '</pre>';
}
}
echo '<pre>';
print_r($result);
echo '</pre>';
?>
|
Up
6. Get region details
This method will return region details
|
Method Signature |
<?php
$result = $client->call('get_region_details', array( $auth_string,
$uniq));
?>
string $auth_string
string $uniq
|
Return array: $result |
Array
(
[country_name] => Israel
[city_name] => Tel-Aviv
[monthly] => 10.00
)
|
Code example |
|
<?php
require_once('lib/nusoap.php');
$site = 'http://sandbox.didww.com/api/?wsdl';
$client = new soapclient($site, true);
$err = $client->getError();
if ($err)
{
echo 'ERROR: ' . $err . '</pre>';
}
$username = 'username@domain.com';
$_key = '1234657890';
$auth_string = sha1($username.$_key."sandbox");
$arr = array();
$arr[0] = $auth_string;
$arr[1] = $uniq;
$result = $client->call('get_region_details', $arr);
if ($client->fault)
{
echo '<pre>';
print_r($result);
echo '</pre>';
}
else
{
$err = $client->getError();
if ($err)
{
echo 'Error: <pre>' . $err . '</pre>';
}
}
echo '<pre>';
print_r($result);
echo '</pre>';
?>
|
Up
7. Get DID details
This method will return DID details
|
Method Signature |
<?php
$result = $client->call('get_did_details', array( $auth_string,
$did_number));
?>
string $auth_string
string $did_number
|
Return array: $result |
Array
(
[did_country_name] => United States
[did_city_name] => New York NY
[did_number_format] => 1-516-700100
[did_status] => Active
[did_timeleft] => 1 mon
[did_expire_date] => 2007-06-23 03:06:27
[did_order_id] => 123456
[did_order_status] => Completed
[did_autorenew] => Disabled
[did_mapping_format] => SIP/212.150.36.116/1516700100
[did_mapping_default] => No
[did_id] => 205
[did_price] => 5.00
)
|
Code example |
|
<?php
require_once('lib/nusoap.php');
$site = 'http://sandbox.didww.com/api/?wsdl';
$client = new soapclient($site, true);
$err = $client->getError();
if ($err)
{
echo 'ERROR: ' . $err . '</pre>';
}
$username = 'username@domain.com';
$_key = '1234657890';
$auth_string = sha1($username.$_key."sandbox");
$arr = array();
$arr[0] = $auth_string;
$arr[1] = $did_number;
$result = $client->call('get_did_details', $arr);
if ($client->fault)
{
echo '<pre>';
print_r($result);
echo '</pre>';
}
else
{
$err = $client->getError();
if ($err)
{
echo 'Error: <pre>' . $err . '</pre>';
}
}
echo '<pre>';
print_r($result);
echo '</pre>';
?>
|
Up
8. Order autorenew status
This method will change Auto-renew status.
0 - Disable Auto-renew
1 - Enable Auto-Renew
|
Method Signature |
<?php
$result = $client->call('order_autorenew_status', array($auth_string,
$did_number,
$autorenew));
?>
string $auth_string
string $did_number
integer $autorenew
|
Return integer: $result |
|
|
Code example |
|
<?php
require_once('lib/nusoap.php');
$site = 'http://sandbox.didww.com/api/?wsdl';
$client = new soapclient($site, true);
$err = $client->getError();
if ($err)
{
echo 'ERROR: ' . $err . '</pre>';
}
$username = 'username@domain.com';
$_key = '1234657890';
$auth_string = sha1($username.$_key."sandbox");
$arr = array();
$arr[0] = $auth_string;
$arr[1] = $did_number;
$arr[2] = $autorenew; //0 - Disable, 1 - Enable
$result = $client->call('order_autorenew_status', $arr);
if ($client->fault)
{
echo '<pre>';
print_r($result);
echo '</pre>';
}
else
{
$err = $client->getError();
if ($err)
{
echo 'Error: <pre>' . $err . '</pre>';
}
}
echo '<pre>';
print_r($result);
echo '</pre>';
?>
|
Up
9. Renew DID
This method will renew DID for provided period (months).
Valid periods are: 1, 3, 6, 12, 24 Months
Autorenew: 0 - Disable, 1 - Enable
|
Method Signature |
<?php
$result = $client->call('new_order_renew', array($auth_string,
$did_number,
$period,
$autorenew));
?>
string $auth_string
string $did_number
integer $period
integer $autorenew
|
Return array: $result |
Array
(
[did_country_name] => United States
[did_city_name] => New York NY
[did_number_format] => 1-516-700100
[did_status] => Active
[did_timeleft] => 2 mon
[did_expire_date] => 2007-07-23 03:06:27
[did_order_id] => 123457
[did_order_status] => Pending
[did_autorenew] => Disabled
[did_mapping_format] => SIP/212.150.36.116/1516700100
[did_mapping_default] => No
[did_id] => 205
)
|
Code example |
|
<?php
require_once('lib/nusoap.php');
$site = 'http://sandbox.didww.com/api/?wsdl';
$client = new soapclient($site, true);
$err = $client->getError();
if ($err)
{
echo 'ERROR: ' . $err . '</pre>';
}
$username = 'username@domain.com';
$_key = '1234657890';
$auth_string = sha1($username.$_key."sandbox");
$arr = array();
$arr[0] = $auth_string;
$arr[1] = $did_number;
$arr[2] = $period; // 1,3,6,12,24 Months
$arr[3] = $autorenew; //0 - Disable, 1 - Enable
$result = $client->call('new_order_renew', $arr);
if ($client->fault)
{
echo '<pre>';
print_r($result);
echo '</pre>';
}
else
{
$err = $client->getError();
if ($err)
{
echo 'Error: <pre>' . $err . '</pre>';
}
}
echo '<pre>';
print_r($result);
echo '</pre>';
?>
|
Up
10. Cancel DID
This method will cancel DID.
Note: Canceled DIDs cannot be restored.
|
Method Signature |
<?php
$result = $client->call('did_cancel', array($auth_string,
$did_number));
?>
string $auth_string
string $did_number
|
Return integer: $result |
|
|
Code example |
|
<?php
require_once('lib/nusoap.php');
$site = 'http://sandbox.didww.com/api/?wsdl';
$client = new soapclient($site, true);
$err = $client->getError();
if ($err)
{
echo 'ERROR: ' . $err . '</pre>';
}
$username = 'username@domain.com';
$_key = '1234657890';
$auth_string = sha1($username.$_key."sandbox");
$arr = array();
$arr[0] = $auth_string;
$arr[1] = $did_number;
$result = $client->call('did_cancel', $arr);
if ($client->fault)
{
echo '<pre>';
print_r($result);
echo '</pre>';
}
else
{
$err = $client->getError();
if ($err)
{
echo 'Error: <pre>' . $err . '</pre>';
}
}
echo '<pre>';
print_r($result);
echo '</pre>';
?>
|
Up
11. Cancel Order
This method will cancel any Pending Order.
Note: Canceled Orders cannot be restored. Sandbox does not support this function.
|
Method Signature |
<?php
$result = $client->call('order_cancel', array($auth_string,
$did_number));
?>
string $auth_string
string $did_number
|
Return integer: $result |
|
|
|
|
Up
|
|