Download the PHP package acrnogor/flowroute-sdk-v3-php without Composer
On this page you can find all versions of the php package acrnogor/flowroute-sdk-v3-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download acrnogor/flowroute-sdk-v3-php
More information about acrnogor/flowroute-sdk-v3-php
Files in acrnogor/flowroute-sdk-v3-php
Package flowroute-sdk-v3-php
Short Description The Flowroute APIs are organized around REST. Our APIs have resource-oriented URLs, support HTTP Verbs, and respond with HTTP Status Codes. All API requests and responses, including errors, will be represented as JSON objects. You can use the Flowroute APIs to manage your Flowroute phone numbers including setting primary and failover routes for inbound calls, and sending text messages (SMS and MMS) using long-code or toll-free numbers in your account.
License MIT
Homepage https://apimatic.io
Informations about the package flowroute-sdk-v3-php
Flowroute PHP Library v3
The Flowroute PHP Library v3 provides methods for interacting with Numbers v2 – which includes inbound voice routes, E911 addresses, and CNAM storage – and Messages v2.1 of the Flowroute API.
Topics
- Requirements
- Installation
-
Usage
- Configuration
- Credentials
- API Client and Controllers
-
Functions
-
Number Management
- GetAvailableAreaCodes
- GetAvailableExchangeCodes
- GetAvailableNumbers
- GetNumbers
- GetNumberDetails
-
Route Management
- CreateInboundRoute
- GetInboundRoutes
- UpdatePrimaryRoute
- UpdateFailoverRoute
-
Messaging
- SendSMS
- GetMessages
- GetMDRDetail
-
E911 Address Management
- listE911s
- get_e911_details
- validate_address
- create_address
- update_address
- associate_did
- list_dids_for_address
- unassociate_did
- delete_address
- CNAM Record Management
- GetCNAMs
- getCNAMdetails
- createCNAM
- associateCNAM
- unassociateCNAM
- deleteCNAM
-
- Errors
- Testing
- Configuration
-
- *
Requirements
- Flowroute API credentials
- PHP 5.4.0 or higher
-
Composer 1.1.6 or higher
-
- *
Installation
-
First, start a shell session and clone the SDK:
via HTTPS:
git clone https://github.com/flowroute/flowroute-sdk-v3-php.git
via SSH:
[email protected]:flowroute/flowroute-sdk-v3-php.git
-
Switch to the newly-created flowroute-sdk-v3-php directory.
-
Download Composer in the same directory. PHP Library v3 comes with a composer.json listing the project dependencies and other metadata. Run the following:
php composer.phar install
Usage
In Flowroute's approach to building the PHP library v3, HTTP requests are handled by an API client object accessed by functions defined in testSDK.php which interacts with the Numbers, Routes, and Messages API resources, e911_demo.php which interacts with the E911s resource, and cnam_demo.php which interacts with the CNAMs resouce. All demo files are located within the test subdirectory. First, switch to the test directory and open the demo file that you need to test.
Change directory
cd test
Open test file
The following shows an example of a single PHP file that imports the Flowroute API client and all the required modules. The PHP Library v3 comes with three example demo files — testSDK.php, e911_demo.php, cnam_demo.php — files that you can edit and run for demonstration and testing purposes.
vim testSDK.php
Configuration
Credentials
In testSDK.php, check that the required files are included at the top. Replace username with your API Access Key and password with your API Secret Key from the Flowroute Manager. Note that in our example, we are accessing your Flowroute credentials as environment variables. To learn more about setting environment variables, see How To Read and Set Environmental and Shell Variables.
<?php
require_once "../vendor/autoload.php";
require_once "../src/Configuration.php";
use FlowrouteNumbersAndMessagingLib\Models;
// Access your Flowroute API credentials as local environment variables
$username = getenv('FR_ACCESS_KEY', true) ?: getenv('FR_ACCESS_KEY');
$password = getenv('FR_SECRET_KEY', true) ?: getenv('FR_SECRET_KEY');
Instantiate the API Client
// Instantiate API client and authenticate
$client = new FlowrouteNumbersAndMessagingLib\FlowrouteNumbersAndMessagingClient($username, $password);
Functions
The following section will demonstrate the capabilities of Numbers v2, Messages v2.1, E911s v2, and CNAMs v2 that are wrapped in our PHP library. Note that the example responses may not show the expected results from the function calls within testSDK.php, e911_demo.php, and cnam_demo.php. These examples have been formatted using Mac's pbpaste and jq. To learn more, see Quickly Tidy Up JSON from the Command Line.
Number Management
Flowroute PHP Library v3 allows you to make HTTP requests to the numbers resource of Flowroute API v2: https://api.flowroute.com/v2/numbers
GetAvailableAreaCodes($client)
The function declares limit, offset, and maxSetupCost as parameters which you can learn more about in the API reference.
Function Declaration
function GetAvailableAreaCodes($client)
{
$return_list = array();
$limit = 2;
$offset = 0;
$maxSetupCost = 10.00;
// User the Numbers Controller from our Client
$numbers = $client->getNumbers();
do
{
echo "Offset is " . $offset;
$areacode_data = $numbers->ListAvailableAreaCodes($limit, $offset, $maxSetupCost);
var_dump($areacode_data);
foreach ($areacode_data as $item)
{
echo "---------------------------\nAvailable Area Code:\n";
var_dump($item);
$return_list[] = $item;
}
// See if there is more data to process
$links = $areacode_data->links;
if (isset($links->next))
{
// more data to pull
$offset += $limit;
}
else
{
break; // no more data
}
} while (true);
return $return_list;
}
Example Response
On success, the HTTP status code in the response header is 200 OK and the response body contains an array of area code objects in JSON format.
{
"data": [
{
"type": "areacode",
"id": "201",
"links": {
"related": "https://api.flowroute.com/v2/numbers/available/exchanges?areacode=201"
}
},
{
"type": "areacode",
"id": "202",
"links": {
"related": "https://api.flowroute.com/v2/numbers/available/exchanges?areacode=202"
}
},
{
"type": "areacode",
"id": "203",
"links": {
"related": "https://api.flowroute.com/v2/numbers/available/exchanges?areacode=203"
}
}
],
"links": {
"self": "https://api.flowroute.com/v2/numbers/available/areacodes?max_setup_cost=3&limit=3&offset=0",
"next": "https://api.flowroute.com/v2/numbers/available/areacodes?max_setup_cost=3&limit=3&offset=3"
}
}
GetAvailableExchangeCodes($client)
The function declares limit, offset, maxSetupCost, and areacode as parameters which you can learn more about in the API reference.
Function Declaration
function GetAvailableExchangeCodes($client)
{
$return_list = array();
$limit = 10;
$offset = 0;
$maxSetupCost = 174.40;
$areacode = "206";
// User the Numbers Controller from our Client
$numbers = $client->getNumbers();
do
{
$exchanges_data = $numbers->ListAvailableExchangeCodes($limit, $offset, $maxSetupCost, $areacode);
var_dump($exchanges_data);
foreach ($exchanges_data as $item)
{
echo "---------------------------\nAvailable Exchange:\n";
var_dump($item);
$return_list[] = $item;
}
// See if there is more data to process
$links = $exchanges_data->links;
if (isset($links->next))
{
// more data to pull
$offset += $limit;
}
else
{
break; // no more data
}
}
while (true);
return $return_list;
}
Example Response
On success, the HTTP status code in the response header is 200 OK and the response body contains an array of exchange objects in JSON format.
{
"data": [
{
"type": "exchange",
"id": "347215",
"links": {
"related": "https://api.flowroute.com/v2/numbers/available?starts_with=1347215"
}
},
{
"type": "exchange",
"id": "347325",
"links": {
"related": "https://api.flowroute.com/v2/numbers/available?starts_with=1347325"
}
},
{
"type": "exchange",
"id": "347331",
"links": {
"related": "https://api.flowroute.com/v2/numbers/available?starts_with=1347331"
}
}
],
"links": {
"self": "https://api.flowroute.com/v2/numbers/available/exchanges?areacode=347&limit=3&offset=0",
"next": "https://api.flowroute.com/v2/numbers/available/exchanges?areacode=347&limit=3&offset=3"
}
}
GetAvailableNumbers($client)
The function declares startsWith, contains, endsWith, rateCenter, state, limit, and offset as parameters which you can learn more about in the API reference.
Function Declaration
function GetAvailableNumbers($client)
{
$startsWith = "206";
$contains = NULL;
$endsWith = NULL;
$rateCenter = NULL;
$state = NULL;
$limit = 2;
$offset = 0;
$return_list = array();
// User the Numbers Controller from our Client
$numbers = $client->getNumbers();
do
{
$number_data = $numbers->SearchForPurchasablePhoneNumbers($startsWith, $contains,
$endsWith, $limit, $offset, $rateCenter, $state);
var_dump($number_data);
// Iterate through each number item
foreach ($number_data as $item)
{
echo "---------------------------\nAvailable Area Codes:\n";
var_dump($item);
$return_list[] = $item;
}
// See if there is more data to process
$links = $number_data->links;
if (isset($links->next))
{
// more data to pull
$offset += $limit;
}
else
{
break; // no more data
}
} while (true);
return $return_list;
}
Example Response
On success, the HTTP status code in the response header is 200 OK and the response body contains an array of phone number objects in JSON format.
{
"data": [
{
"attributes": {
"rate_center": "nwyrcyzn01",
"value": "16463439507",
"monthly_cost": 1.25,
"state": "ny",
"number_type": "standard",
"setup_cost": 1
},
"type": "number",
"id": "16463439507",
"links": {
"related": "https://api.flowroute.com/v2/numbers/16463439507"
}
},
{
"attributes": {
"rate_center": "nwyrcyzn01",
"value": "16463439617",
"monthly_cost": 1.25,
"state": "ny",
"number_type": "standard",
"setup_cost": 1
},
"type": "number",
"id": "16463439617",
"links": {
"related": "https://api.flowroute.com/v2/numbers/16463439617"
}
},
{
"attributes": {
"rate_center": "nwyrcyzn01",
"value": "16463439667",
"monthly_cost": 1.25,
"state": "ny",
"number_type": "standard",
"setup_cost": 3.99
},
"type": "number",
"id": "16463439667",
"links": {
"related": "https://api.flowroute.com/v2/numbers/16463439667"
}
}
],
"links": {
"self": "https://api.flowroute.com/v2/numbers/available?contains=3&ends_with=7&starts_with=1646&limit=3&offset=0",
"next": "https://api.flowroute.com/v2/numbers/available?contains=3&ends_with=7&starts_with=1646&limit=3&offset=3"
}
}
GetNumbers($client)
The function declares startsWith, contains, endsWith, rateCenter, state, limit, and offset as parameters which you can learn more about in the API reference.
Function Declaration
function GetNumbers($client)
{
$return_list = array();
// List all phone numbers in our account paging through them 1 at a time
// If you have several phone numbers, change the 'limit' variable below
// This example is intended to show how to page through a list of resources
// create a numbers instance
$numbers = $client->getNumbers();
// query all our numbers
$startsWith = 1646;
$endsWith = NULL;
$contains = NULL;
$limit = 3;
$offset = 0;
$result = $numbers->getAccountPhoneNumbers($startsWith, $endsWith, $contains, $limit, $offset);
//var_dump($result);
foreach($result as $item) {
foreach($item as $entry) {
var_dump($entry);
echo "--------------------------------------\n";
$return_list[] = $entry;
}
echo "--------------------------------------\n";
}
return $return_list;
}
Example Response
On success, the HTTP status code in the response header is 200 OK and the response body contains an array of phone number objects in JSON format.
{
"data": [
{
"attributes": {
"rate_center": "oradell",
"value": "12012673227",
"alias": null,
"state": "nj",
"number_type": "standard",
"cnam_lookups_enabled": true
},
"type": "number",
"id": "12012673227",
"links": {
"self": "https://api.flowroute.com/v2/numbers/12012673227"
}
},
{
"attributes": {
"rate_center": "jerseycity",
"value": "12014845220",
"alias": null,
"state": "nj",
"number_type": "standard",
"cnam_lookups_enabled": true
},
"type": "number",
"id": "12014845220",
"links": {
"self": "https://api.flowroute.com/v2/numbers/12014845220"
}
}
],
"links": {
"self": "https://api.flowroute.com/v2/numbers?starts_with=1201&limit=3&offset=0"
}
}
GetNumberDetails($client, string id)
The function declares the id as a variable which you can learn more about in the API reference. In the following example, we request the details of the first phone number returned after calling the list_account_phone_numbers method.
Function Declaration
function GetNumberDetails($client, $id)
{
// User the Numbers Controller from our Client
$numbers = $client->getNumbers();
echo "Calling gnd with " . $id;
$result = $numbers->getPhoneNumberDetails($id);
var_dump($result);
return $result;
}
Example Response
On success, the HTTP status code in the response header is 200 OK and the response body contains a phone number object in JSON format.
{
"included": [
{
"attributes": {
"route_type": "sip-reg",
"alias": "sip-reg",
"value": null
},
"type": "route",
"id": "0",
"links": {
"self": "https://api.flowroute.com/v2/routes/0"
}
}
],
"data": {
"relationships": {
"cnam_preset": {
"data": null
},
"e911_address": {
"data": null
},
"failover_route": {
"data": null
},
"primary_route": {
"data": {
"type": "route",
"id": "0"
}
}
},
"attributes": {
"rate_center": "millbrae",
"value": "16502390214",
"alias": null,
"state": "ca",
"number_type": "standard",
"cnam_lookups_enabled": true
},
"type": "number",
"id": "16502390214",
"links": {
"self": "https://api.flowroute.com/v2/numbers/16502390214"
}
},
"links": {
"self": "https://api.flowroute.com/v2/numbers/16502390214"
}
}
Route Management
The Flowroute PHP Library v3 allows you to make HTTP requests to the routes resource of Flowroute API v2: https://api.flowroute.com/v2/routes
CreateInboundRoute($client)
The function declares the route object in JSON format as a parameter which you can learn more about in the API reference. In the following example, we declare a test route with route_type "host".
Function Declaration
function CreateInboundRoute($client)
{
$routes = $client->getRoutes();
$body = new Models\NewRoute();
$body->data = new Models\Data61();
$body->data->attributes = new Models\Attributes62();
$body->data->attributes->alias = "Test Route";
$body->data->attributes->routeType = Models\RouteTypeEnum::HOST;
$body->data->attributes->value = "www.flowroute.com";
$result = $routes->CreateAnInboundRoute($body);
var_dump($result);
}
Example Response
On success, the HTTP status code in the response header is 201 Created and the response body contains a route object in JSON format.
{
"data": {
"attributes": {
"alias": "Test Route",
"route_type": "host",
"value": "www.flowroute.com"
},
"id": "98396",
"links": {
"self": "https://api.flowroute.com/routes/98396"
},
"type": "route"
},
"links": {
"self": "https://api.flowroute.com/routes/98396"
}
}
GetInboundRoutes($client, $DID, $route_id)
The function declares limit and offset as parameters which you can learn more about in the API reference.
Function Declaration
function GetInboundRoutes($client)
{
$return_list = array();
$limit = 3;
$offset = 0;
$routes = $client->getRoutes();
do
{
$route_data = $routes->ListInboundRoutes($limit, $offset);
var_dump($route_data);
foreach ($route_data->data as $item)
{
echo "---------------------------\nInbound Routes:\n";
var_dump($item);
$return_list[] = $item;
}
// See if there is more data to process
$links = $route_data->links;
if (isset($links->next))
{
// more data to pull
$offset += $limit;
}
else
{
break; // no more data
}
}
while (true);
return $return_list;
}
Example Response
On success, the HTTP status code in the response header is 200 OK and the response body contains an array of route objects in JSON format.
{
"data": [
{
"attributes": {
"route_type": "sip-reg",
"alias": "sip-reg",
"value": null
},
"type": "route",
"id": "0",
"links": {
"self": "https://api.flowroute.com/v2/routes/0"
}
},
{
"attributes": {
"route_type": "number",
"alias": "PSTNroute1",
"value": "12065551212"
},
"type": "route",
"id": "83834",
"links": {
"self": "https://api.flowroute.com/v2/routes/83834"
}
}
],
"links": {
"self": "https://api.flowroute.com/v2/routes?limit=2&offset=0",
"next": "https://api.flowroute.com/v2/routes?limit=2&offset=2"
}
}
UpdatePrimaryRoute($client, $DID, $route_id)
The function updates a DID with the route_id parameter which you can learn more about in the API reference.
Function Declaration
function UpdatePrimaryRoute($client, $DID, $route_id)
{
$routes = $client->getRoutes();
$result = $routes->UpdatePrimaryVoiceRouteForAPhoneNumber($DID, $route_id);
var_dump($result);
}
Example Response
On success, the HTTP status code in the response header is 204 No Content which means that the server successfully processed the request and is not returning any content.
204 No Content
UpdateFailoverRoute($client, $DID, $route_id)
The function updates a DID with the route_id parameter which you can learn more about in the API reference.
Function Declaration
function UpdateFailoverRoute($client, $DID, $route_id)
{
$routes = $client->getRoutes();
$result = $routes->UpdateFailoverVoiceRouteForAPhoneNumber($DID, $route_id);
var_dump($result);
}
Example Response
On success, the HTTP status code in the response header is 204 No Content which means that the server successfully processed the request and is not returning any content.
204 No Content
Messaging
The Flowroute PHP Library v3 allows you to make HTTP requests to the messages resource of Flowroute API v2.1: https://api.flowroute.com/v2.1/messages
SendSMS($client, $from_did)
The function declares a message object in JSON format as a parameter which you can learn more about in the API References for MMS and SMS. In the following example, we are sending an SMS from the previously declared from_did to your mobile number.
Function Declaration
function SendSMS($client, $from_did)
{
$msg = new Message();
$msg->From = $from_did;
$msg->To = "YOUR_MOBILE_NUMBER"; // Replace with your mobile number to receive messages from your Flowroute account
$msg->Body = "Hi Chris";
$messages = $client->getMessages;
$result = $messages->CreateSendAMessage($msg);
echo $result;
}
Note that this function call is currently commented out. Uncomment to test the SendSMS function.
Example Response
On success, the HTTP status code in the response header is 202 Accepted and the response body contains the message record ID with mdr2 prefix.
{
"data": {
"links": {
"self": "https://api.flowroute.com/v2.1/messages/mdr2-39cadeace66e11e7aff806cd7f24ba2d"
},
"type": "message",
"id": "mdr2-39cadeace66e11e7aff806cd7f24ba2d"
}
}
GetMessages($client)
The function declares startDate, endDate, limit, and offset as parameters which you can learn more about in the API Reference.
Function Declaration
function GetMessages($client)
{
$return_list = array();
$limit = 1;
$offset = 0;
// Find all messages since January 1, 2017
$startDate = new DateTime('2018-01-01', new DateTimeZone('Pacific/Nauru'));
$endDate = NULL;
do
{
$messages = $client->getMessages();
$message_data = $messages->getLookUpASetOfMessages($startDate, $endDate, $limit, $offset);
// Iterate through each number item
foreach ($message_data->data as $item)
{
echo "---------------------------\nSMS MDR:\n";
echo "Attributes:" . $item->attributes . "\nId:" . $item->id . "\nLinks:" . $item.links . "\nType:" . $item->type . "\n";
$return_list[] = $item->id;
}
// See if there is more data to process
$links = $message_data->links;
if (isset($links->next))
{
// more data to pull
$offset += $limit;
}
else
{
break; // no more data
}
}
while (true);
return $return_list;
}
Example Response
On success, the HTTP status code in the response header is 200 OK and the response body contains an array of message objects in JSON format.
{
"data": [
{
"attributes": {
"body": "Hello are you there? ",
"status": "delivered",
"direction": "inbound",
"amount_nanodollars": 4000000,
"to": "12012673227",
"message_encoding": 0,
"timestamp": "2017-12-22T01:52:39.39Z",
"delivery_receipts": [],
"amount_display": "$0.0040",
"from": "12061231234",
"is_mms": false,
"message_type": "longcode"
},
"type": "message",
"id": "mdr2-ca82be46e6ba11e79d08862d092cf73d"
},
{
"attributes": {
"body": "test sms on v2",
"status": "message buffered",
"direction": "outbound",
"amount_nanodollars": 4000000,
"to": "12061232634",
"message_encoding": 0,
"timestamp": "2017-12-21T16:44:34.93Z",
"delivery_receipts": [
{
"status": "message buffered",
"status_code": 1003,
"status_code_description": "Message accepted by Carrier",
"timestamp": "2017-12-21T16:44:35.00Z",
"level": 2
},
{
"status": "smsc submit",
"status_code": null,
"status_code_description": "Message has been sent",
"timestamp": "2017-12-21T16:44:35.00Z",
"level": 1
}
],
"amount_display": "$0.0040",
"from": "12012673227",
"is_mms": false,
"message_type": "longcode"
},
"type": "message",
"id": "mdr2-39cadeace66e11e7aff806cd7f24ba2d"
}
],
"links": {
"next": "https://api.flowroute.com/v2.1/messages?limit=2&start_date=2017-12-01T00%3A00%3A00%2B00%3A00&end_date=2018-01-08T00%3A00%3A00%2B00%3A00&offset=2"
}
}
GetMDRDetail($client, $id)
The function declares a message id in MDR2 format as a variable which you can learn more about in the API Reference. In the following example, we retrieve the details of the first message in our look_up_a_set_of_messages search result.
Function Declaration
function GetMDRDetail($client, $id)
{
$messages = $client->Messages;
$mdr_data = $messages->GetLookUpAMessageDetailRecord($id);
echo $mdr_data;
}
Example Response
On success, the HTTP status code in the response header is 200 OK and the response body contains the message object for our specified message id.
{
"data": {
"attributes": {
"body": "Hello are you there? ",
"status": "delivered",
"direction": "inbound",
"amount_nanodollars": 4000000,
"to": "12012673227",
"message_encoding": 0,
"timestamp": "2017-12-22T01:52:39.39Z",
"delivery_receipts": [],
"amount_display": "$0.0040",
"from": "12061232634",
"is_mms": false,
"message_type": "longcode"
},
"type": "message",
"id": "mdr2-ca82be46e6ba11e79d08862d092cf73d"
}
}
E911 Address Management
The Flowroute PHP Library v3 allows you to make HTTP requests to the e911s resource of Flowroute API v2: https://api.flowroute.com/v2/e911s
All of the E911 address management methods are encapsulated in e911_demo.php
.
listE911s($client)
The function declares limit, offset, and state as parameters which you can learn more about in the API reference.
Function Declaration
Example Response
On success, the HTTP status code in the response header is 200 OK and the response body contains an array of e911 objects in JSON format. Note that this demo function iterates through all the E911 records on your account filtered by the parameters that you specify. The following example response has been clipped for brevity's sake.
get_e911_details($detail_id)
The function declares a variable, detail_id
, as a parameter which you can learn more about in the API reference. The value that gets assigned to detail_id
is the first resulting item of the returned array from the listE911s
function call.
Function Declaration
Example Response
On success, the HTTP status code in the response header is 200 OK
and the response body contains a detailed e911 object in JSON format.
validate_address($e911_object)
In the following example request, we instantiate body
as an E911Record
object, then initialize its different attributes with example values. The different attributes that an E911Record
object can have include label
, first_name
, last_name
, street_name
, street_numbe r
, address_type
, address_type_number
, city
, state
, country
, and zipcode
. Learn more about the different body parameters in the API reference. We then pass body
as a parameter for the validate_address
function.
Example Request
Example Response
On success, the HTTP status code in the response header is 204 No Content
which means that the server successfully processed the request and is not returning any content. On error, a printable representation of the detailed API response is displayed.
create_address($e911_object)
The method accepts an E911 object with its different attributes as a parameter. Learn more about the different E911 attributes in the API reference. In the following example request, we pass our E911Record
object, body
, as a parameter to the create_address
method.
Example Request
Example Response
On success, the HTTP status code in the response header is 201 Created
and the response body contains the newly created e911 object in JSON format. On error, a printable representation of the detailed API response is displayed.
update_address($e911_object, $detail_id)
The method accepts an E911 object and an E911 record ID. Learn more about the different E911 attributes that you can update in the API reference. In the following example, we will retrieve the record ID of our newly created E911 address and assign it to a variable, detail_id
. We then update the label
of our selected E911 address to "Work".
Example Request
Example Response
On success, the HTTP status code in the response header is 200 OK
and the response body contains the newly updated e911 object in JSON format. On error, a printable representation of the detailed API response is displayed.
associate_did($did_id, $detail_id)
The method accepts a phone number and an E911 record ID as parameters which you can learn more about in the API reference. In the following example, we call the getAccountPhoneNumbers function covered under Number Management to extract the value of the first item in the returned JSON array into variable did_id
, pass our previously declared detail_id
for the E911 record ID, and then make the association between them.
Example Request
Example Response
On success, the HTTP status code in the response header is 204 No Content
which means that the server successfully processed the request and is not returning any content.
list_dids_for_address($detail_id)
The method accepts an E911 record id as a parameter which you can learn more about in the API reference. In the following example, we retrieve the list of phone numbers associated with our previously assigned detail_id
.
Example Request
Example Response
On success, the HTTP status code in the response header is 200 OK
and the response body contains an array of related number objects in JSON format.
unassociate_did($did_id)
The method accepts a phone number as a parameter which you can learn more about in the API reference. In the following example, we deactivate the E911 service for our previously assigned did_id
.
Example Request
Example Response
On success, the HTTP status code in the response header is 204 No Content
which means that the server successfully processed the request and is not returning any content.
delete_address($detail_id)
The method accepts an E911 record ID as a parameter which you can learn more about in the API reference. Note that all phone number associations must be removed first before you are able to delete the specified detail_id
. In the following example, we will attempt to delete the previously assigned detail_id
.
Example Request
Example Response
On success, the HTTP status code in the response header is 204 No Content
which means that the server successfully processed the request and is not returning any content.
CNAM Record Management
The Flowroute PHP Library v3 allows you to make HTTP requests to the cnams
resource of Flowroute API v2: https://api.flowroute.com/v2/cnams
.
All of the CNAM record management methods are encapsulated in cnam_demo.php
.
GetCNAMs($client, approval_status)
The method accepts a client object and all the different CNAM query parameters which you can learn more about in the API reference. In the following example request, we will only retrieve approved CNAM records. Note that this demo function iterates through all the E911 records on your account filtered by the parameters t hat you specify. The following example response has been clipped for brevity's sake.
Function Declaration
Example Request
Example Response
On success, the HTTP status code in the response header is 200 OK
and the response body contains an array of cnam objects in JSON format.
getCNAMdetails($cnam_id)
The method accepts a CNAM record ID as a parameter which you can learn more about in the API reference. In the following example, we query for approved CNAM records on your account and then extract the ID of the first record returned and retrieve the details of that specific CNAM record.
Example Request
Example Response
On success, the HTTP status code in the response header is 200 OK
and the response body contains a detailed cnam object in JSON format.
createCNAM($cnam_value)
The method accepts a Caller ID value as a parameter which you can learn more about in the API reference. In the following example, we include a generateRandomString
function to generate a four-character random string which we will concatenate with Flowroute and assign as our CNAM value. Note that you can enter up to 15 characters for your CNAM value.
CNAM Storage Rules |
---|
You can enter up to 15 characters for your CNAM value at least one of which is a letter. |
While most CNAM presets can be approved, the following are not allowed and must be rejected: |
- Consist of curse words and/or is inappropriate. |
- A phone number (CNAM must be a name not a number) |
- If the CNAM preset which the customer has submitted appears to be misleading such as: |
- Political Figures or Places (Obama, Barack or The White House) |
- False or fake CNAM (Seattle Police) |
Example Request
Example Response
On success, the HTTP status code in the response header is 201 Created
and the response body contains the newly created cnam object in JSON format. This demo includes a wait_for_user()
function which gives you a confirmation of the CNAM record creation then prompts you to press "Enter". Afterwards, you should see a message on the limitation around CNAM record and phone number association.
associateCNAM($cnam_id, $did)
The method accepts a CNAM record ID and a phone number as parameters which you can learn more about in the API reference. In the following example, we will call getNumbers()
and getCNAMs()
then associate the first number with the first CNAM record in the resulting numbers and CNAMs arrays. This demo includes a wait_for_user()
function which gives you a confirmation of the CNAM record association with the phone number and prompts you to press "Enter" to continue.
Example Request
Example Response
On success, the HTTP status code in the response header is 202 Accepted
and the response body contains an attributes dictionary containing the date_created
field and the assigned cnam object in JSON format. This request will fail if the CNAM you are trying to associate has not yet been approved.
unassociateCNAM($did)
The method accepts a phone number as a parameter which you can learn more about in the API reference. In the following example, we will disassociate the same phone number that we've used in associate_cnam()
. This demo includes a wait_for_user()
function which gives you a confirmation of the CNAM record disassociation from the phone number and prompts you to press "Enter" to continue.
Example Request
Example Response
On success, the HTTP status code in the response header is 202 Accepted
and the response body contains an attributes object with the date the CNAM was requested to be disassociated, and the updated cnam object in JSON format.
deleteCNAM($cnam_id)
The method accepts a CNAM record ID as a parameter which you can learn more about in the API reference. In the following example, we will be deleting our previously extracted cnam_id
from the "List Approved CNAM Records" function call. This demo includes a wait_for_user()
function which gives you a confirmation of the CNAM record deletion and prompts you to press "Enter" to continue.
Example Request
Example Response
On success, the HTTP status code in the response header is 204 No Content
which means that the server successfully processed the request and is not returning any content.
Errors
In cases of method errors, the PHP Library v3 raises an exception which includes an error message and the HTTP body that was received in the request.
Example Error
Testing
Once you are done configuring your Flowroute API credentials and updating the function parameters, you can run any of the demo files to see them in action. The Flowroute library demo files are named after the resource they represent:
php e911_demo.php
All versions of flowroute-sdk-v3-php with dependencies
ext-curl Version *
ext-json Version *
ext-mbstring Version *
mashape/unirest-php Version ~3.0.1
apimatic/jsonmapper Version ~1.3.0