【发布时间】:2018-02-18 22:49:24
【问题描述】:
我希望您能帮助我解决使用 Plivo PHP(新 SDK 4.0)拨打电话的问题。首先,我将说明我想要实现的目标: - 我网站上的一个客户想和main的代理交谈,所以他在表格中介绍了他的电话号码,选择了一个代理,最后在提交时,网站连接了他们两个拨号(这个工作)。但是,(从这里开始我的问题),我无法根据其中一些详细信息检索呼叫详细信息(状态、持续时间、呼叫的初始和结束日期等...)以便为客户开具发票。
2018 年 2 月 23 日编辑:
Ramya,600 错误已消失,一切似乎都正常,正如我在 Plivo 调试日志中看到的那样。以下是我的新代码(我认为由于您的指示做得更好),然后我向您展示 Plivo debud 日志(也许您可以在我的帐户,2018 年 2 月 23 日 18:33:15 拨打电话),最后我看到 我的服务器调试错误日志为空!
主要问题是 dialstatus.php 文件,虽然似乎接收了参数,但我不知道如何访问它们,因为 dialstatus.php 没有执行在我的监视器中显示数据(例如在我的代码中,这个线永远不会显示在监视器屏幕上:)
echo "Status = $estado, Aleg UUID = $aleg, Bleg UUID = $bleg";
因此,即使它接收到参数,我也无法访问它们来操作它们、在屏幕上打印它们、对它们执行 ifs 等。这可能是文件的权限问题吗? (这些php文件在我的服务器上有6,4,4的权限,和其他的一样)。
谢谢!
代码 1:makecall.php
require 'vendor/autoload.php';
use Plivo\RestClient;
$client = new RestClient("**********", "**************************");
$telefono_cliente = "34*******";
$telefono_experto = "34*********";
$duracion = 50;
try {
$response = $client->calls->create(
"3491111111",
[$telefono_experto],
"https://www.ejemplo.com/llamar/response.php?telf=$telefono_cliente",
'POST',
[
'time_limit' => $duracion,
]
);
$id = $response->requestUuid;
echo "<br>Este es el requestUuid: " . $id . "<br><br>";
}
catch (PlivoRestException $ex) {
print_r($ex);
}
?>
代码 2:response.php
require 'vendor/autoload.php';
use Plivo\XML\Response;
$resp = new Response();
$params = array(
'callerId' => '3491111111',
'action' => "https://www.ejemplo.com/llamar/dialstatus.php",
'method' => "POST",
'redirect' => "false"
);
$body3 = 'Desde ejemplo un cliente desea hablar con usted.';
$params3 = array(
'language' => "es-ES", # Language used to read out the text.
'voice' => "WOMAN" # The tone to be used for reading out the text.
);
$resp->addSpeak($body3,$params3);
$dial = $resp->addDial($params);
//$number = "34**********";
$number = $_GET['telf'];
$dial->addNumber($number);
Header('Content-type: text/xml');
echo($resp->toXML());
/*
Output:
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Speak language="es-ES" voice="WOMAN">Desde ejemplo un cliente desea hablar con usted.</Speak>
<Dial redirect="false" method="POST" action="http://www.ejemplo.com/llamar/dialstatus.php" callerId="3491111111">
<Number>34********</Number>
</Dial>
</Response>
*/
?>
代码 3:dialstatus.php
// Print the Dial Details
$estado = $_REQUEST['DialStatus'];
$aleg = $_REQUEST['DialALegUUID'];
$bleg = $_REQUEST['DialBLegUUID'];
echo "Status = $estado, Aleg UUID = $aleg, Bleg UUID = $bleg";
?>
【问题讨论】:
标签: php status phone-call duration plivo