【发布时间】:2019-04-28 12:12:41
【问题描述】:
我正在开发一个通过 AGI/PHP 脚本与数据库集成的按分钟付费呼叫服务。我已经很好地完成了集成部分,但我对如何以不暴露任何一方的个人信息(例如 CID 信息)的方式将客户与提供商联系起来感到困惑。此外,我必须能够跟踪两方连接的时间(以便准确计费)。
基本上,以下是调用流程的概要:
- 客户端请求与应用程序上的提供者交谈
- 该应用会生成一个 6 位数的访问代码,供他们拨打 800 号码时使用
- 客户拨打热线电话,输入接入码
- 服务器通过 AGI 连接到数据库并检索与访问代码关联的提供商的手机号码
- 服务器调用提供者并宣布“用户某某在线”。用户某某此时只能听到暂停的音乐
- 提供商按一个键(例如英镑)接听电话或按另一个键拒绝
- 服务器向双方宣布“您的电话正在接通,现在开始计费”之类的信息
- 服务器连接双方并让开,但开始计时,直到信道中断
- 通话结束后,定时器值通过 AGI 记录到数据库中
有什么想法吗?我已经在互联网上搜索了好几个小时,甚至找不到任何与我想做的事情很接近的例子。
如果有人可以提供任何帮助,或者如果有人有任何示例并且过去做过类似的事情,我将不胜感激。
编辑:
这是我的拨号方案:
exten => 1,1,Read(acode,enter_acode,6)
same => Set(ACODE = ${acode})
same => n,agi(baba.agi,get_call,${acode})
same => n,GotoIf($["${CALLSTAT}" == "1"]?call-ok:call-bad)
same => n(call-bad),GotoIf($["${CALLSTAT}" == "2"]?ag-unavail:call-not-found)
same => n(call-not-found),Playback(acode_invalid)
same => n,Goto(baba,1,1)
same => n(ag-unavail),Read(opt,ag_unavail,1)
same => n,GotoIf($["${opt}" == "1"]?ag-notify:no-call)
same => n(ag-notify),agi(baba.agi,ag_notify,${ACODE})
same => n,GotoIf($["${NSTAT}" == "1"]?notify-ok:call-error)
same => n(notify-ok),Playback(ag_notify)
same => n,Goto(baba,s,1)
same => n(call-ok),Read(opt,call_ready,1)
same => n,GotoIf($["${opt}" == "1"]?start-call:no-call)
same => n(start-call),Playback(attempt_connect)
HERE IS WHERE I WANT TO CALL ${APHONE}
same => n,Goto(no-call)
same => n(no-call),Playback(no_call)
same => n,Goto(baba,s,1)
same => n(call-error),Playback(error_proc_req)
same => n,Goto(baba,s,1)
这是我的 PHP agi 中的函数:
function get_call()
{
global $db;
log_agi("Retrieving call information for access code: {$this->agi_arg_2}");
$q = "SELECT * FROM `call-user` WHERE `call_code`='%s' AND `call_status`=1 LIMIT 1";
$q = sprintf($q,$this->agi_arg_2);
$res = $db->query($q);
db_error($db,$q);
if ($res->num_rows > 0)
{
$call = $res->fetch_object();
log_agi("Call #{$call->call_id} found! Checking agent availability...");
if ($call->ag_avail)
{
log_agi("Agent is available! User Phone: {$call->user_phone}, Agent Phone: {$call->ag_phone}");
execute_agi("SET VARIABLE CALLSTAT 1");
execute_agi("SET VARIABLE UPHONE {$call->user_phone}");
execute_agi("SET VARIABLE APHONE {$call->ag_phone}");
return true;
}else{
log_agi("Agent [{$call->ag_username}] is unavailable!");
execute_agi("SET VARIABLE CALLSTAT 2");
return false;
}
}else{
log_agi("Call associated with access code #{$this->agi_arg_2} was not found!");
execute_agi("SET VARIABLE CALLSTAT 0");
return false;
}
}
谢谢!
【问题讨论】:
-
我也希望能够做到这一点。 IE。客户端可以向提供者请求回调。
-
所以要求您与我们分享您的代码尝试或其他努力。 “任何想法?”不允许提问。