Wallogit.com
2017 © Pedro Peláez
oneyun-server-api-php sdk
composer require oneyun/sdk
calls示例, (*1)
语音回拨发起, (*2)
calls->create(
'17606661993',
'13611460986',
array(
'user_data'=>'',
'max_dial_duration'=>30
)
);
var_dump($res); //返回结果
```
语音回拨挂断
```php
calls->cancel(
'callId'
);
var_dump($result); //返回结果
```
### 语音通知
> notifyCall示例
```php
notifyCall->create(
'17606661993',
$play_content,
array(
'user_data'=>'',
'max_dial_duration'=>30,
'play_file'=>'语音通知.wav'
)
);
```
### 语音验证码
> verfiyCall示例
```php
verfiyCall->create(
'17606661993',
'8888',
array(
'user_data'=>'',
'max_dial_duration'=>30
)
);
```
### IVR呼出
> ivrCall示例
```php
ivrCall->create(
'17606661993',
array(
'user_data'=>'',
'max_dial_duration'=>30
)
);
```
### IVR
####放音
> play示例
```
play('文件名.wav');
$ivr->next('http://localhost/ivr.php?step=hangup');
//输出
echo $ivr;
```
输出结果
```
<response>
<play>文件名.wav</play>
<next>http://localhost/ivr.php?step=hangup</next>
</response>
playlist示例, (*3)
$ivr = new Oneyun\Ivr();
$ivr->playlist(
array(
'文件名1.wav',
'文件名2.wav'
)
);
$ivr->next('http://localhost/ivr.php?step=hangup');
echo $ivr;
输出结果, (*4)
<?xml version="1.0" encoding="UTF-8"?>
<response>
<playlist>
<play>文件名1.wav</play>
<play>文件名2.wav</play>
</playlist>
<next>http://localhost/ivr.php?step=hangup</next>
</response>
record示例, (*5)
$ivr = new Oneyun\Ivr();
$ivr->record();
$ivr->next('http://localhost/ivr.php?step=hangup');
echo $ivr;
输出结果, (*6)
<?xml version="1.0" encoding="UTF-8"?> <response> <record></record> <next>http://localhost/ivr.php?step=hangup</next> </response>
get示例, (*7)
$ivr = new Oneyun\Ivr();
$ivr->get(
'get.wav'
);
$ivr->next('http://localhost/ivr.php?step=hangup');
echo $ivr;
输出结果, (*8)
<response> <get valid_keys="0123456789#" finish_keys="#"> <play>get.wav</play> </get> <next>http://localhost/ivr.php?step=hangup</next> </response>
hangup示例, (*9)
$ivr = new Oneyun\Ivr(); $ivr->hangup(); echo $ivr;
输出结果, (*10)
<?xml version="1.0" encoding="UTF-8"?> <response> <hangup></hangup> </response>
dial示例, (*11)
$ivr = new Oneyun\Ivr();
$ivr->dial('17606661993');
$ivr->next('http://localhost/ivr.php?step=hangup');
echo $ivr;
输出结果, (*12)
<?xml version="1.0" encoding="UTF-8"?>
<response>
<dial>
<number>17606661993</number>
<connect><connect/>
</dial>
<next>http://localhost/ivr.php?step=hangup</next>
</response>
next示例, (*13)
$ivr = new Oneyun\Ivr(); $ivr->next();
<?php
require __DIR__."/vendor/autoload.php";
$appId = ""; //应用标识
$certId = ""; //鉴权Id
$apiUrl = ""; //接口地址
$secreKey = "";//密钥
$oneyun = new Oneyun\Rest\Client($appId, $certId, $apiUrl, $secreKey);
$options = array(
'type'=>1,
'user'=>'10222',
'password'=>'123456'
);
$options = array(
'type'=>1, // 分机类型
'user'=>'test001', // 分机号 6-12位数字
'password'=>'123456' // 分机密码
);
$res = $oneyun->callcenter->createExt($options);
var_dump($res); //返回结果
$extension_id = '8a2a6a4a59965bab0159968f95840000'; // 分机ID $res = $oneyun->callcenter->deleteExt($extension_id);
$extension_id = '8a2a6a4a59965bab0159968f95840000'; // 分机ID $res = $oneyun->callcenter->findExt($extension_id);
$pageNo = 1; // 第几页 $pageSize = 20; // 每页显示数量 $res = $oneyun->callcenter->findAllExt($pageNo,$pageSize);
$agent_name = 'test001'; //坐席名称
$extension = '8a2a6a4a59965bab0159968f95840000'; // 绑定的分机ID
$options = array(
'num'=>'123456', // 坐席工号
'state'=>'idle' // 坐席状态 idle 为空闲
);
$res = $oneyun->callcenter->agentLogin($agent_name,$extension,$options);
$agent_name = 'test001'; //坐席名称 $force = true; // true 为强制注销 $res = $oneyun->callcenter->agentLogout($agent_name,$force);
$agent_name = 'test001'; //坐席名称 $res = $oneyun->callcenter->agentKeep($agent_name);
$agent_name = 'test001'; //坐席名称 $res = $oneyun->callcenter->findAgent($agent_name);
$pageNo = 1; // 第几页 $pageSize = 20; // 每页显示数量 $res = $oneyun->callcenter->findAllAgent($pageNo, $pageSize);
$agent_name = 'test001'; //坐席名称 $extension_id = '8a2a6a4a59965bab0159968f95840000'; // 分机ID $res = $oneyun->callcenter->setAgentExt($agent_name,$extension_id )
$agent_name = 'test001'; //坐席名称 $state = 'idle'; // 坐席状态 $res = $oneyun->callcenter->setAgentState($agent_name,$state);
$agent_name = 'test001'; //坐席名称
// 坐席技能
$opts = array(
array(
'opt'=>1,
'name'=>'test', // 坐席名称
'score'=>80, // 坐席技能分
'enabled'=>true // 是否启用技能
)
);
$res = $oneyun->callcenter->setAgentSkills($agent_name,$opts);
// public function createCondition($where = '', $queue_timeout = 0,$options = array())
$where = 'get('test')>60;'; // 条件表达式 必须;号结尾
$queue_timeout = 30; // 排队等待超时时间 (0-1000)
$options = array(
'fetch_timeout'=>30, // 坐席分机接听超时时间(秒)(0-60)
'priority'=>99, // 数值大的优先级高 (0-99)
'remark'=>'', // 备注
);
$res = $oneyun->callcenter->createCondition($where,$queue_timeout,$options);
$condition_id = ''; // 排队条件 $res = $oneyun->callcenter->deleteCondition($condition_id);
$condition_id = ''; //排队条件ID
$where = 'get('test')>60;'; // 条件表达式 必须;号结尾
$options = array(
'fetch_timeout'=>30, // 坐席分机接听超时时间(秒)(0-60)
'priority'=>99, // 数值大的优先级高 (0-99)
'remark'=>'', // 备注
);
$res = $oneyun->callcenter->editCondition($condition_id,$where,$options);
$condition_id = ''; //排队条件ID $res = $oneyun->callcenter->findCondition($condition_id);
$res = $oneyun->callcenter->findAllCondition();
$conversation_id = ''; // 交谈ID $res = $oneyun->callcenter->deleteConversation($conversation_id);
$conversation_id = ''; // 交谈ID $agent_name = ''; // 坐席名称 $mode = 1; // 设置坐席听说模式 (1-4) $res = $oneyun->callcenter->setConversationMode($conversation_id,$agent_name,$mode);
$conversation_id = ''; // 交谈ID
$enqueue = '<enqueue wait_voice="wait.wav" ring_mode="1" play_num="true" user_data="test">
<route><agent name="test001" priority="11" queue_timeout="60" fetch_timeout="50"></agent></route>
</enqueue>'; // 目标坐席选择条件
$mode = 1; // 设置坐席听说模式 (1-4)
$res = $oneyun->callcenter->setConversationInviteAgent($conversation_id,$enqueue,$mode);
$conversation_id = ''; // 交谈ID
$to = '17606661993'; // 被叫号码
$max_answer_seconds = 180; // 最大通话时间
$options = array(
'from'=>'', // 主叫号码
'max_dial_seconds' => 60, // 最大拨号等待时间
'mode'=>1 // 加入后的听/说模式
);
$res = $oneyun->callcenter->setConversationInviteOut($conversation_id,$to,$max_answer_seconds,$options);
$conversation_id = ''; // 交谈ID $res = $oneyun->callcenter->findConversation($conversation_id);
$res = $oneyun->callcenter->findAllConversation();
$agent_name = 'test001'; // 坐席名称 $queue_id = ''; // 排队任务ID $data = 'user_data'; // 自定义数据 $res = $oneyun->callcenter->setAgentRejectTask($agent_name,$queue_id,$data);
$agent_name = 'test001'; // 坐席名称
$to = '17606661993'; // 被叫号码
$max_answer_seconds = 180; // 最大通话时间
$options = array(
'from'=>'', // 主叫号码
'max_dial_seconds' => 60, // 最大拨号等待时间
'user_data'=>'自定义数据'
);
$res = $oneyun->callcenter->setAgentCallOut($agent_name,$to,$max_answer_seconds,$options);
$agent_name = 'test001'; // 坐席名称
$enqueue = '<enqueue wait_voice="wait.wav" ring_mode="1" play_num="true" user_data="test">
<route><agent name="test001" priority="11" queue_timeout="60" fetch_timeout="50"></agent></route>
</enqueue>'; // 目标坐席选择条件
$res = $oneyun->callcenter->setAgentCallAgent($agent_name,$enqueue);
$agent_name = 'test001'; // 坐席名称
$queue_task_id = '';
$enqueue = '<enqueue wait_voice="wait.wav" ring_mode="1" play_num="true" user_data="test">
<route><agent name="test001" priority="11" queue_timeout="60" fetch_timeout="50"></agent></route>
</enqueue>'; // 目标坐席选择条件
$res = $oneyun->callcenter->setAgentFwdAgent($agent_name,$queue_task_id,$enqueue);
$agent_name = 'test001'; // 坐席名称
$conversation_id = ''; // 交谈ID
$enqueue = '<enqueue wait_voice="wait.wav" ring_mode="1" play_num="true" user_data="test">
<route><agent name="test001" priority="11" queue_timeout="60" fetch_timeout="50"></agent></route>
</enqueue>'; // 目标坐席选择条件
$res = $oneyun->callcenter->setAgentXferAgent($agent_name,$conversation_id,$enqueue);
$agent_name = 'test001'; // 坐席名称
$conversation_id = ''; // 交谈ID
$max_answer_seconds = 180; // 最大通话时间
$options = array(
'from'=>'', // 主叫号码
);
$res = $oneyun->callcenter->setAgentXferOut($agent_name,$conversation_id,$to,$max_answer_seconds,$options);
$agent_name = 'test001'; // 坐席名称 $conversation_id = ''; // 交谈ID $mode = 1; // 设置坐席听说模式 (1-4) $res = $oneyun->callcenter->setAgentMode($agent_name,$conversation_id,$mode);
$agent_name = 'test001'; // 坐席名称 $conversation_id = ''; // 交谈ID $mode = 1; // 设置坐席听说模式 (1-4) $holding = true; $res = $oneyun->callcenter->setAgentEnter($agent_name,$conversation_id,$mode,$holding);
$agent_name = 'test001'; // 坐席名称 $conversation_id = ''; // 交谈ID $res = $oneyun->callcenter->setAgentOut($agent_name,$conversation_id);
$agent_name = 'test001'; // 坐席名称 $src_conversation_id = ''; // 交谈ID1 $dst_conversation_id = ''; // 交谈ID2 $mode = 1; // 设置坐席听说模式 (1-4) $res = $oneyun->callcenter->setAgentMerge($agent_name,$src_conversation_id,$dst_conversation_id,$mode);
$agent_name = 'test001'; // 坐席名称 $res = $oneyun->callcenter->findAgentConversation($agent_name);
<?php
require __DIR__."/vendor/autoload.php";
$appId = ""; //应用标识
$certId = ""; //鉴权Id
$apiUrl = ""; //接口地址
$secreKey = "";//密钥
$oneyun = new Oneyun\Rest\Client($appId, $certId, $apiUrl, $secreKey);
$options = [
'callbackUrl' => 'http://101.200.135.23:8088/callback/1',
'remark'=>'test3',
'quotas' =>[]
];
$res = $oneyun->management->createSubAccount($options);
var_dump($res); //返回结果
$id = ''; // 子账号ID
$options = array(
'callbackUrl'=>'http://...', // 回调url
'remark'=> '', // 备注
'enabled'=>1 // 是否启用
);
$res = $oneyun->callcenter->editSubAccount($id,$options);
$id = ''; // 子账号ID $res = $oneyun->callcenter->deleteSubAccount($id);
$pageNo = 1; $pageSize = 20; $res = $oneyun->callcenter->findAllSubAccount($pageNo,$pageSize);
$pageNo = 1; $pageSize = 20;, (*14)
$id = ''; // 子账号ID $res = $oneyun->callcenter->findSubAccount($id);
$id = ''; // 子账号ID
$quotas = array(
array(
'type'=>'AgentQuota', // 呼叫中心坐席配额
'value'=>1000
),
array(
'type'=>'CallQuota', // 通话时长配额
'value'=>1000
),
array(
'type'=>'ussdQuota', // 闪印配额
'value'=>1000
),
array(
'type'=>'smsQuota', // 短信配额
'value'=>1000
)
);
$res = $oneyun->callcenter->setSubAccountQuotas($id,$quotas);
php
$pageNo = 1;
$pageSize = 20;
$res = $oneyun->callcenter->findAllTelNum($pageNo,$pageSize);, (*15)
### 查询号码列表, (*16)
php
$pageNo = 1;
$pageSize = 20;
$res = $oneyun->callcenter->findAllTelNum($pageNo,$pageSize);, (*17)
### 号码绑定子账号, (*18)
php
$id = ''; // 号码资源ID
$subaccountId = ''; // 子账号ID
$res = $oneyun->callcenter->bindTelNum($id,$subaccountId);
### 号码解绑子账号, (*19)
php
$id = ''; // 号码资源ID
$subaccountId = ''; // 子账号ID
$res = $oneyun->callcenter->unBindTelNum($id,$subaccountId);, (*20)