voximplant/apiclient-php
Composer 安装命令:
composer require voximplant/apiclient-php
包简介
Voximplant PHP API client library. Voximplant is a cloud communications platform for business and developers
README 文档
README
Version 3.9.0
Prerequisites
In order to use the Voximplant PHP SDK, you need the following:
- A developer account. If you don't have one, sign up here.
- A private API key. There are 2 options to obtain it:
- Either generate it in the Voximplant Control panel
- Or call the CreateKey HTTP API method with the specified authentication parameters. You'll receive a response with the result field in it. Save the result value in a file (since we don't store the keys, save it securely on your side).
How to use
To install the bindings via Composer, add the following to composer.json:
{
"require": {
"voximplant/apiclient-php": "*@dev"
}
}
Then run
composer install
Next, specify the path to the file with the result value either in the constructor or using the environment.
constructor:
$options = (object)[ 'tokenPath' => 'path/to/private/api/key.json', ]; $voxApi = new VoximplantApi($options);
env:
$_ENV['VOXIMPLANT_CREDENTIALS_PATH'] = 'path/to/private/api/key.json';
From now on you have access to the SDK methods.
Examples
Start a scenario
use Voximplant\VoximplantApi; use Voximplant\Resources\Params\StartScenariosParams; // Create options $options = (object)[ 'tokenPath' => 'path/to/private/api/key.json', ]; // Create API Object $voxApi = new VoximplantApi($options); /** * @param array $params (See below) * rule_id - The rule ID. * script_custom_data - The script custom data (like a script argument). Can be accessed in JS scenario via the VoxEngine.customData() method */ $params = new StartScenariosParams(); $params->rule_id = 1; $params->script_custom_data = 'mystr'; // Start the scripts from the account. $result = $voxApi->Scenarios->StartScenarios($params); // Show result print_r($result);
Send an SMS
use Voximplant\VoximplantApi; use Voximplant\Resources\Params\SendSmsMessageParams; // Create options $options = (object)[ 'tokenPath' => 'path/to/private/api/key.json', ]; // Create API Object $voxApi = new VoximplantApi($options); /** * @param array $params (See below) * source - The source phone number. * destination - The destination phone number. * sms_body - The message. */ $params = new SendSmsMessageParams(); $params->source = '447443332211'; $params->destination = '447443332212'; $params->sms_body = 'Test message'; // Send the SMS message with text "Test message" from the phone number 447443332211 to the phone number 447443332212. $result = $voxApi->SMS->SendSmsMessage($params); // Show result print_r($result);
Get a call history item
use Voximplant\VoximplantApi; use Voximplant\Resources\Params\GetCallHistoryParams; // Create options $options = (object)[ 'tokenPath' => 'path/to/private/api/key.json', ]; // Create API Object $voxApi = new VoximplantApi($options); /** * @param array $params (See below) * from_date - The from date in the selected timezone in 24-h format: YYYY-MM-DD HH:mm:ss * to_date - The to date in the selected timezone in 24-h format: YYYY-MM-DD HH:mm:ss * count - The max returning record count. * timezone - The selected timezone or the 'auto' value (will be used the account location). */ $params = new GetCallHistoryParams(); $params->from_date = '2012-01-01 00:00:00'; $params->to_date = '2014-01-01 00:00:00'; $params->count = 1; $params->timezone = 'Etc/GMT'; // Get the first call session history record from the 2012-01-01 00:00:00 UTC to the 2014-01-01 00:00:00 UTC $result = $voxApi->History->GetCallHistory($params); // Show result print_r($result);
Get the transaction history
use Voximplant\VoximplantApi; use Voximplant\Resources\Params\GetTransactionHistoryParams; // Create options $options = (object)[ 'tokenPath' => 'path/to/private/api/key.json', ]; // Create API Object $voxApi = new VoximplantApi($options); /** * @param array $params (See below) * from_date - The from date in the selected timezone in 24-h format: YYYY-MM-DD HH:mm:ss * to_date - The to date in the selected timezone in 24-h format: YYYY-MM-DD HH:mm:ss * count - The max returning record count. * transaction_type - The transaction type list. The following values are possible: periodic_charge, resource_charge, money_distribution, subscription_charge, subscription_installation_charge, card_periodic_payment, card_overrun_payment, card_payment, robokassa_payment, gift, add_money, subscription_cancel, adjustment, wire_transfer, refund. * timezone - The selected timezone or the 'auto' value (will be used the account location). */ $params = new GetTransactionHistoryParams(); $params->from_date = '2012-01-01 00:00:00'; $params->to_date = '2014-01-01 00:00:00'; $params->count = 3; $params->transaction_type = array ( 0 => 'gift', 1 => 'money_distribution', ); $params->timezone = 'Etc/GMT'; // Get the three transactions record from the 2012-01-01 00:00:00 UTC to the 2014-01-01 00:00:00 UTC with the 'gift' or 'money_distribution' types. $result = $voxApi->History->GetTransactionHistory($params); // Show result print_r($result);
voximplant/apiclient-php 适用场景与选型建议
voximplant/apiclient-php 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 64.64k 次下载、GitHub Stars 达 9, 最近一次更新时间为 2019 年 06 月 06 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「sms」 「communication」 「messaging」 「video」 「chat」 「call」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 voximplant/apiclient-php 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 voximplant/apiclient-php 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 voximplant/apiclient-php 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Dispatcher to handle e-mail and instant notifications.
Package to publish/consume domain events messages from Laravel apps
SDK for payment gateway PlatbaMobilom.sk for PHP7.0
Manage Node resources from PHP
PHP SDK for Mobile Message SMS API
Extensible library for building notifications and sending them via different delivery channels.
统计信息
- 总下载量: 64.64k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 9
- 点击次数: 34
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Apache-2.0
- 更新时间: 2019-06-06