PHP wrapper for the Digium Switchvox API.
This makes simple Switchvox's requests in JSON or XML.
Digium's PHP client library requires a PEAR and PECL package whereas this implementation does not require them.
$client = new Switchvox\SwitchvoxClient();
$client->user = 'admin';
$client->password = '1234';
$client->uri = 'https://somedigiumendpoint.com';
// By default it will not care if the SSL cert is valid, to change:
$client->strict_ssl = true;
// Timeout in seconds, default is 10 seconds
$client->timeout = 15;
// If JSON is preferred (default):
$client->data_type = 'json';
// If XML is preferred:
$client->data_type = 'xml';
// Request a method with parameters
$params = [
'sort_field' => 'number',
'sort_order' => 'ASC',
'items_per_page' => '9999',
'page_number' => '1'
];
$response = $client->send('switchvox.directories.getExtensionList', $params);
// Request without parameters
$response = $client->send('switchvox.directories.getInfo');
The strict_ssl
feature correlates to the Httpful\Request timeout.
All Digium Switchvox web service methods can be found here.
The send
method returns a Httpful\Response object.
To run tests in phpunit you must use your own environment variables for user and password:
$ SWITCHVOX_USER=<user> SWITCHVOX_PASSWORD=<password> phpunit -v --debug
For development you can get a free demo Digium Switchbox account.
They will send you a user name and passowrd to your email address.
Once you log into the admin portal take note of the domain name and use that as the uri.
The uri
property for this client and the phpunit.xml file is pre-populated with:
https://switchvoxdemo1.digiumcloud.net
Digium Switchvox API is PSR-0 compliant and can be installed using composer. Simply add shrimpwagon/digium-switchvox-api
to your composer.json file. Composer is the sane alternative to PEAR. It is excellent for managing dependencies in larger projects.
{
"require": {
"shrimpwagon/digium-switchvox-api": "*"
}
}
Digium Switchvox API highly encourages sending in pull requests. When submitting a pull request please:
dev
branch (not master
)phpunit ./tests