wearesho-team / evrotel
此包已被弃用且不再维护。未建议替代包。
Evrotel API 集成
6.0.0
2019-07-07 20:56 UTC
Requires
- php: >=7.2
- ext-json: *
- guzzlehttp/guzzle: ^6.3
- horat1us/environment-config: ^1.2
- nesbot/carbon: ^1.30
- wearesho-team/base-collection: ^1.0
Requires (Dev)
- phpunit/phpunit: ^7.4
- squizlabs/php_codesniffer: ^3.3
- dev-master
- 6.0.0
- 5.0.0
- 4.0.0
- 3.0.0
- 2.0.0
- 1.5.3
- 1.5.2
- 1.5.1
- 1.5.0
- 1.4.0
- 1.3.0
- 1.2.0
- 1.1.0
- 1.0.0
- 1.0.0-RC1
- dev-feature/autodial-disposition
- dev-feature/cghooks
- dev-hotfix/beautify-test-configs
- dev-hotfix/functions-lookup-optimize
- dev-hotfix/receiver-request-validation-optimize
- dev-hotfix/receiver-request-optimize
- dev-hotfix/receiver-optimization
This package is auto-updated.
Last update: 2020-07-03 07:54:58 UTC
README
此库使用 API 文档 创建
安装
composer require wearesho-team/evrotel
使用
配置
您可以使用 Config 来配置应用程序。此外,还提供了 环境配置。
- EVROTEL_TOKEN,字符串 - 从 Evrotel 管理员处收到的令牌
- EVROTEL_BILL_CODE,整数 - 从 Evrotel 管理员处收到的账单代码
- EVROTEL_BASE_URL,字符串,默认
http://m01.sipiko.net/
- 统计文件的基础 URL - EVROTEL_AUTO_DIAL_URL,字符串,默认
https://autodial.evro-tel.com.ua/autodialapi/call_worker_api.php
,自动拨号请求的 URL。
统计信息
您可以使用 Config 来配置统计客户端。此外,还提供了 环境配置。
- EVROTEL_STATISTICS_BASE_URL,字符串,默认
https://callme.sipiko.net/
- 统计请求的基础 URL - EVROTEL_STATISTICS_AUTODIAL_NUMBER,字符串,默认
null
- 如果指定,所有标记为相同from
的统计呼叫都将标记为自动拨号。
接收者
<?php use Wearesho\Evrotel; /** @var Evrotel\ConfigInterface $config */ $receiver = new Evrotel\Receiver($config); try { $request = $receiver->getRequest(); if($request instanceof Evrotel\Receiver\Request\Start) { /** * You have to return ID in response body * to receive it in call end request */ return 1; } elseif ($request instanceof Evrotel\Receiver\Request\End) { // Do something with call end request return; } } catch (Evrotel\Exceptions\AccessDenied $denied) { // Return 403 } catch(Evrotel\Exceptions\BadRequest $badRequest) { // Return 400 }
自动拨号
在开始呼叫之前,您需要推送媒体文件
<?php use Wearesho\Evrotel; /** @var Evrotel\ConfigInterface $config */ /** @var GuzzleHttp\Client $client */ $repository = new Evrotel\AutoDial\MediaRepository($config, $client); $link = 'https://server.com/file.wav'; // Public link to auto dial file, Mono, 16 Bits,8000Hz, wav try { $fileName = $repository->push($link); } catch(Evrotel\Exceptions\AutoDial\PushMedia $media) { // handle errors }
推送媒体后,您可以使用文件进行拨号
<?php use Wearesho\Evrotel; /** @var Evrotel\ConfigInterface $config */ /** @var GuzzleHttp\Client $client */ $worker = new Evrotel\AutoDial\Worker($config, $client); /** @var string $fileName returned from MediaRepository */ /** @var string $phone in format 380XXXXXXXXX */ $request = new Evrotel\AutoDial\Request($fileName, $phone); $worker->push($request);
统计信息
<?php use Wearesho\Evrotel; $baseConfig = new Evrotel\Config($token = 'token', $billCode = 6667); $config = new Evrotel\Statistics\Config; /** @var GuzzleHttp\Client $guzzle */ $client = new Evrotel\Statistics\Client($baseConfig, $config, $guzzle); $client->getCalls($isAuto = true);
请参阅 Statistics\Call 以获取详细信息。
初始化器
要初始化呼叫,您需要使用 Initializer\Client。
<?php use Wearesho\Evrotel; /** @var Evrotel\Config $config */ /** @var GuzzleHttp\Client $guzzle */ $client = new Evrotel\Initializer\Client($config, $guzzle); $operators = [ '101', '102', ]; try { $client->start('380970000000', $operators); } catch(\RuntimeException $exception) { // Evrotel returned `bad` response }