Diamondcard.us API Example

order DIDs  |  add account  |  update account  |  manage accounts  |  manage DIDs

DID Type:
Country:
DID Type: Country: State:
DID Code: Quantity: Duration: Unique Key:
Order ID:
Add Account
UserName: Password:
Amount: Unlimited balance:
Firstname: Lastname:
Email: Phone:
Do not send notification email to new account
Account Id:
Account Id: Amount:
Update Account
Account Id:
Status
SpeedDial:Code and number pairs separated by coma. CODE1_NUMBER1,CODE2_NUMBER2. 'OFF' value will remove all speed dial numbers
Pinless: Pinless numbers separated by coma. 'OFF' value will remove all pinless numbers.
Caller ID: Number:
Number:
Number: Account Id: Exp. date(mm/dd/yyyy):
Number: Account Id: Redirect: AutoRenew:
Number: Duration: Unique Key:
Result: "; } // Load countries list if ($_REQUEST['action'] == 'countries') { $params = array ('AuthKey' => $AUTH_CODE, // Authorization key 'DidType' => $_REQUEST['didType']); // Do sending $res = sendRequest('did_listcountries', $params); if ($res->ErrMsg) { // Fail print "Error: ".$res->ErrMsg."
"; // Error message } else { // Success print "Country code,Country name
"; print implode("
", $res->Countries)."
"; } } // Load states list else if ($_REQUEST['action'] == 'states') { $params = array ('AuthKey' => $AUTH_CODE, // Authorization key 'Country' => $_REQUEST['country']); // Do sending $res = sendRequest('did_liststates', $params); if ($res->ErrMsg) { // Fail print "Error: ".$res->ErrMsg."
"; // Error message } else { // Success print "State Code
"; print implode("
", $res->States)."
"; } } // Load DID cicites with prices else if ($_REQUEST['action'] == 'didlist') { $params = array ('AuthKey' => $AUTH_CODE, // Authorization key 'DidType' => $_REQUEST['didType'], 'Country' => $_REQUEST['country'], 'State' => $_REQUEST['state']); // Do sending $res = sendRequest('did_list', $params); if ($res->ErrMsg) { // Fail print "Error: ".$res->ErrMsg."
"; // Error message } else { // Success print "DidCode,City,Prefix,Setup Price,Monthly Price
"; print implode("
", $res->List)."
"; } } // Order DID else if ($_REQUEST['action'] == 'order') { $params = array ('AuthKey' => $AUTH_CODE, // Authorization key 'DidCode' => $_REQUEST['didCode'], 'Quantity' => $_REQUEST['quantity'], 'UniqKey' => $_REQUEST['uniqueKey'], 'Duration' => $_REQUEST['duration']); // Do sending $res = sendRequest('order_did', $params); if ($res->ErrMsg) { // Fail print "Error: ".$res->ErrMsg."
"; // Error message } else { // Success print "DID ordered.
"; print "Status: ".$res->Status."
"; print "OrderId: ".$res->OrderId."
"; if ($res->Numbers) { print "Assigned numbers: ".$res->Numbers."\n"; } } } else if ($_REQUEST['action'] == 'order_info') { $params = array ('AuthKey' => $AUTH_CODE, // Authorization key 'OrderId' => $_REQUEST['OrderId']); // Do sending $res = sendRequest('order_info', $params); if ($res->ErrMsg) { // Fail print "Error: ".$res->ErrMsg."
"; // Error message } else { // Success print "DID order info.
"; print "Status: ".$res->Status."
"; if ($res->Numbers) { print "Assigned numbers: ".$res->Numbers."\n"; } } } else if ($_REQUEST['action'] == 'acc_add') { $params = array ('AuthKey' => $AUTH_CODE, // Authorization key 'UserName' => $_REQUEST['Username'], 'Password' => $_REQUEST['Password'], 'BalanceType' => $_REQUEST['UnlimBalance'], 'Amount' => $_REQUEST['Amount'], 'Currency' => $_REQUEST['Currency'], 'FirstName' => $_REQUEST['FirstName'], 'LastName' => $_REQUEST['LastName'], 'Email' => $_REQUEST['Email'], 'NoMail' => $_REQUEST['NotifyAcc'], 'DayPhone' => $_REQUEST['Phone']); // Do sending $res = sendRequest('acc_add', $params); if ($res->ErrMsg) { // Fail print "Error: ".$res->ErrMsg."
"; // Error message } else { // Success print "Account added.
"; print "New account Id: ".$res->AccId."
"; print "New account Pin Code: ".$res->PinCode."
"; } } else if ($_REQUEST['action'] == 'acc_info') { $params = array ('AuthKey' => $AUTH_CODE, // Authorization key 'AccId' => $_REQUEST['AccId']); // Do sending $res = sendRequest('acc_info', $params); if ($res->ErrMsg) { // Fail print "Error: ".$res->ErrMsg."
"; // Error message } else { // Success print "Account ".$_REQUEST['AccId']." info
"; print "Status: ".$res->Status."
"; print "PinCode: ".$res->PinCode."
"; if ($res->Balanceype == 'unlim') { print "Unlimited balance. Curent value: ".$res->Balance." ".$res->Currency."
"; } else { print "Balance ".$res->Balance." ".$res->Currency."
"; } print "
"; print "FirstName: ".$res->FirstName."
"; print "LastName: ".$res->LastName."
"; print "Email: ".$res->Email."
"; print "DayPhone: ".$res->DayPhone."
"; print "
"; print "SpeedDial numbers: ".$res->SpeedDial."
"; print "Pinless numbers: ".$res->Pinless."
"; print "CallerId: ".$res->CallerId."
"; } } else if ($_REQUEST['action'] == 'acc_recharge') { $params = array ('AuthKey' => $AUTH_CODE, // Authorization key 'AccId' => $_REQUEST['AccId'], 'Amount' => $_REQUEST['Amount'], 'Currency' => $_REQUEST['Currency']); // Do sending $res = sendRequest('acc_recharge', $params); if ($res->ErrMsg) { // Fail print "Error: ".$res->ErrMsg."
"; // Error message } else { // Success print "Account recharged.
"; print "New Balance: ".$res->Balance." ".$res->Currency."
"; } } else if ($_REQUEST['action'] == 'acc_update') { $callerId=''; if ($_REQUEST['CallerIdSwitch'] == 'ON' ){ $callerId = 'ON_'.$_REQUEST['CallerId']; } else if ($_REQUEST['CallerIdSwitch'] == 'OFF' ){ $callerId = 'OFF'; } $params = array ('AuthKey' => $AUTH_CODE, // Authorization key 'AccId' => $_REQUEST['AccId'], 'Status' => $_REQUEST['Status'], 'SpeedDial' => $_REQUEST['SpeedDial'], 'Pinless' => $_REQUEST['Pinless'], 'CallerId' => $callerId); // Do sending $res = sendRequest('acc_update', $params); if ($res->ErrMsg == 'OK') { // Success print "Account updated"; } else { // Fail print "Error: ".$res->ErrMsg."
"; // Error message } } else if ($_REQUEST['action'] == 'did_info') { $params = array ('AuthKey' => $AUTH_CODE, // Authorization key 'Number' => $_REQUEST['Number']); // Do sending $res = sendRequest('did_info', $params); if ($res->ErrMsg) { // Fail print "Error: ".$res->ErrMsg."
"; // Error message } else { // Success print "DID ".$_REQUEST['Number']." info.
"; print "Expiration date: ".$res->ExpDate."
"; print "Redirect rule: ".$res->Redirect."
"; print "AutoRenew: ".$res->AutoRenew."
"; if ($res->SubAccId) { print "
"; print "Assigned to sub account: ".$res->SubAccId."
"; print "Sub account expiration date: ".$res->SubExpDate."
"; print "Sub account autoRenew: ".$res->SubAutoRenew."
"; if ($res->SubRedirect == 'ASSIGNED') { print "Sub account assigned it to his sub account
"; } else { print "Sub account redirect rule:".$res->SubRedirect."
"; } } } } else if ($_REQUEST['action'] == 'did_assign') { $params = array ('AuthKey' => $AUTH_CODE, // Authorization key 'Number' => $_REQUEST['Number'], 'SubAccId' => $_REQUEST['AccId'], 'ExpDate' => $_REQUEST['ExpDate']); // Do sending $res = sendRequest('did_assign', $params); if ($res->ErrMsg == 'OK') { // Success print "DID assigned"; } else { // Fail print "Error: ".$res->ErrMsg."
"; // Error message } } else if ($_REQUEST['action'] == 'did_update') { $params = array ('AuthKey' => $AUTH_CODE, // Authorization key 'Number' => $_REQUEST['Number'], 'SubAccId' => $_REQUEST['AccId'], 'Redirect' => $_REQUEST['Redirect'], 'AutoRenew' => $_REQUEST['AutoRenew']); // Do sending $res = sendRequest('did_update', $params); if ($res->ErrMsg == 'OK') { // Success print "DID updated"; } else { // Fail print "Error: ".$res->ErrMsg."
"; // Error message } } else if ($_REQUEST['action'] == 'did_renew') { $params = array ('AuthKey' => $AUTH_CODE, // Authorization key 'Number' => $_REQUEST['Number'], 'RenewPeriod' => $_REQUEST['RenewPeriod'], 'UniqKey' => $_REQUEST['uniqueKey']); // Do sending $res = sendRequest('did_renew', $params); if ($res->ErrMsg == 'OK') { // Success print "DID renewed"; } else { // Fail print "Error: ".$res->ErrMsg."
"; // Error message } } // // sendRequest - send request using NuSOAP lib // function sendRequest($func,$params) { global $WSDL; $client = new soapclient($WSDL); try { $result = $client->$func(array('inParams' => $params)); } catch ( Exception $e) { $result->out->ErrMsg = $e->getMessage(); } // echo 'Result:
'; // echo print_r($result); return $result->out; } ?>