很简单我的问题,我想用twilio创建一个记录,但这不起作用,我没有任何错误,只是这不起作用。
在我的控制器中check()当数字是选项#1工作正常,现在当数字是选项2不起作用,现在我在BOLIVIA - SOUTH AMERICA使用。我知道录音在几个国家有效。我认为这不是问题。但阅读文档不一定是这个代码的问题。
twilioController.php
public function check() {
App::import('Vendor', 'Twilio', array('file' => 'Twilio'.DS.'Services'.DS.'Twilio.php'));
$response = new Services_Twilio_Twiml();
$numero_cel = substr($this->request->data['From'],-8);
$callsid_cel = $this->request->data['CallSid'];
$this->loadModel('User');
$this->loadModel('Numero');
$exis_user= $this->User->find('first', array(
'conditions'=>
array('celular'=>$numero_cel)));
if (isset($this->request->data['Digits'])) {
$input = $this->request->data['Digits'];
switch ($input) {
case 1:
$misses=$exis_user['User']['nombres'].' '.$exis_user['User']['apellidos'];
$numero = $this->Numero->find('all', array(
'conditions'=>
array('user_id'=>$exis_user['User']['id'])));
$account_sid = 'ACxxxxxxxxxxxxxxxxxxxxxxx';
$auth_token = 'xxxxxxxxxxxxxxxxxxxxxxxxxx';
$client = new Services_Twilio($account_sid, $auth_token);
foreach($numero as $var)
{
$client->account->messages->create(array(
'To' => $var['Numero']['numero'],
'From' => "+12055189491",
'Body' => "hola ".$var['Numero']['nombre']." la Señora $misses esta en peligro comunicate con ella y ayudala.",
));
}
break ;
case 2:
$this->request->data['Llamada']['CallSid']=$callsid_cel;
$this->request->data['Llamada']['from']=$numero_cel;
if ($this->Llamada->save($this->request->data)) {
}
$response->say("Empiece a grabar despues del tono", array('voice' => 'woman', 'language' => 'es'));
$response->record(array('maxLength' => 30,'action' => 'http://www.xxxxxxxxxx.bo/twilio/listen'));
$this->response->type('text/xml');
$this->response->body($response);
return $this->response;
break ;
case 3:
$gather=$response->say("Empiece a grabar despues del tono", array('voice' => 'woman','language' => 'es'));
$response->record("hola", array('maxLength' => '30','action' => 'http://www.xxxxxxxxxx.bo/twilio/listen'));
$this->response->type('text/xml');
$this->response->body($response);
return $this->response;
break ;
default:
$gather = $response->gather(array('numDigits' => 3, 'timeout' => '10'));
$gather->say("no selecciono un numero valido",
array('voice' => 'alice', 'language' => 'es'));
print $response ;
break ;
}
} else {
$response->say('Suspect access detected. Get out.',
array('voice' => 'alice', 'language' => 'es'));
print $response ;
exit ;
}
}
当数字是选项2时进行测试,然后这是输出:
<Response>
<Say voice="woman" language="es">Empiece a grabar despues del tono</Say>
<Record maxLength="30" action="http://www.xxxxxxxxx.bo/twilio/listen"/>
</Response>
但是当他打电话时,没有任何反应。不工作,记录不工作。
答案 0 :(得分:0)
好的只需要等待,可能需要40秒才能在检查twilio ms页面时做出答案,看看哪个更高。