如果他的twilio电话被呼叫,我正在尝试将呼叫转接到用户电话。
<Input xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Person>
<PersonID>123456</PersonID>
<FirstName>First Name</FirstName>
<LastName>Last Name</LastName>
<Phone>1234567890</Phone>
<Email>username@domain.com</Email>
</Person>
</Input>
上面的代码工作正常,我需要获取通话时间。所以我添加了状态回调URL来拨号。但是它没有向我发送任何状态事件
下面是我的代码
$usr_ph = 'xxxxxxxxxx'; // get user personal phone from database
$twiml = new Twiml();
$twiml->dial($usr_ph);
return $twiml;
我确实尝试过:
$data = array ('statusCallbackEvent' => array('completed'),
statusCallback' => "https://mywebsite.com/get_Call_outcome",
'statusCallbackMethod' => 'POST'
);
$twiml = new Twiml();
$twiml->dial($usr_ph, json_encode($data));
return $twiml;
但是然后我得到错误消息为
$twiml = new Twiml();
$twiml->dial($usr_ph, [
'statusCallbackEvent' => array('completed'),
'statusCallback' => "https://mywebsite.com/get_Call_outcome",
'statusCallbackMethod' => 'POST'
]);
return $twiml;
不确定,但是我想我需要在twilio手机上进行的原始呼叫上添加statusCallbackEvent。
编辑:
现在,我尝试通过添加statusCallbackEvent来更新来电,但它仍未发送任何事件。
SimpleXMLElement::addAttribute() expects parameter 2 to be string, array given
答案 0 :(得分:0)
statusCallback是Number名词的一部分,而不是Dial动词。您可以在下面找到更多详细信息。看看是否能解决问题。
答案 1 :(得分:0)
尝试在号码名词上设置状态代码
$dial->number('+14158675310', [
'statusCallbackEvent' => 'initiated ringing answered completed',
'statusCallback' => 'https://myapp.com/calls/events',
'statusCallbackMethod' => 'POST'
]);