shrimpwagon/digium-switchvox-api

Switchvox API 的 PHP 封装

1.0.0 2016-09-02 21:45 UTC

This package is auto-updated.

Last update: 2024-09-29 04:42:30 UTC


README

Build Status Latest Stable Version Total Downloads License

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 安装。只需将 shrimpwagon/digium-switchvox-api 添加到您的 composer.json 文件中。Composer 是 PEAR 的合理替代品。它非常适合在大型项目中管理依赖关系

{
    "require": {
        "shrimpwagon/digium-switchvox-api": "*"
    }
}

贡献

Digium Switchvox API 高度鼓励提交拉取请求。提交拉取请求时,请

  • 所有拉取请求应针对 dev 分支(而非 master
  • 确保您的代码遵循 编码约定
  • 请使用软制表符(四个空格)而不是硬制表符
  • 确保您为您的更改添加适当的测试覆盖率
  • 通过 phpunit ./tests 在测试目录中运行所有单元测试
  • 在适当的位置包含注释,并添加描述性的拉取请求信息

变更日志

1.0.0

  • 基本的函数,用于使用 XML 或 JSON 调用 API 方法