chinasearch / digium-switchvox-api
Switchvox API 的 PHP 封装,由 Shrimpwagon 分支而来
Requires
- dcarbone/xml-writer-plus: 0.6.*
- nategood/httpful: ^0.2.20
Requires (Dev)
This package is auto-updated.
Last update: 2024-09-30 01:30:25 UTC
README
PHP 封装 Digium Switchvox API。
特性
这使得通过 JSON 或 XML 简化 Switchvox 的请求。
Digium 的 PHP 客户端库 需要 PEAR 和 PECL 包,而此实现则不需要。
使用方法
$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');
注意
strict_ssl 功能与 Httpful\Request 超时 相关。
所有 Digium Switchvox 网络服务方法都可以在这里找到 这里。
send 方法返回一个 Httpful\Response 对象。
测试
要运行 phpunit 中的测试,您必须使用自己的环境变量来设置用户名和密码
$ SWITCHVOX_USER=<user> SWITCHVOX_PASSWORD=<password> phpunit -v --debug
对于开发,您可以获取一个 免费演示 Digium Switchbox 账户。
他们将向您发送用户名和密码到您的电子邮件地址。
一旦您登录到管理员门户,请记下域名并使用它作为 uri。
此客户端的 uri 属性以及 phpunit.xml 文件预先填充为
https://switchvoxdemo1.digiumcloud.net
要求
- PHP >= 5.4
- XMLWriter,如果使用 XML,则从 PHP 5.1.2 开始捆绑和启用
安装
Composer
Digium Switchvox API 符合 PSR-0 标准,可以使用 composer 安装。只需将 chinasearch/digium-switchvox-api 添加到您的 composer.json 文件中。Composer 是 PEAR 的合理替代品。它非常适合管理大型项目中的依赖项。
{
"require": {
"chinasarech/digium-switchvox-api": "*"
}
}
贡献
Digium Switchvox API 非常鼓励提交 pull request。在提交 pull request 时,请
- 所有 pull request 应针对
dev分支(而不是master) - 确保您的代码遵循 编码规范
- 请使用软制表符(四个空格)而不是硬制表符
- 确保您为您的更改添加适当的测试覆盖率
- 通过
phpunit ./tests在测试目录中运行所有单元测试 - 在适当的地方包含注释并添加描述性的 pull request 消息
变更日志
1.0.0
- 通过 XML 或 JSON 调用 API 方法的基本功能
1.1.0
- 将 DIGEST 身份验证更改为 BASIC
1.1.1
- 版本提升