duanhuang7591 2014-11-07 01:20
浏览 74
已采纳

在Twiml找不到记录

is simple my question, I want make a record with twilio, but this dont work, and I dont have any error just this not work.

In my controller check() when the digit is option # 1 works fine, now when the digit is option 2 does not work, now that I'm using in BOLIVIA - SOUTH AMERICA. I have understood that the voice recording works in several countries. I think it would not be the problem. but reading the documentation would not have to be a problem this code.

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 ;
        }


}

doing tests when the digit is option 2, then this is the output:

<Response>
  <Say voice="woman" language="es">Empiece a grabar despues del tono</Say>
  <Record maxLength="30" action="http://www.xxxxxxxxx.bo/twilio/listen"/>
</Response>

but when he made the call, nothing happens. dont work and Record dont work.

  • 写回答

1条回答 默认 最新

  • dousheyan0375 2014-11-07 14:26
    关注

    okay just need to wait, it may take 40 seconds to make the answer on check the page of twilio ms, and see which is higher.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 unity第一人称射击小游戏,有demo,在原脚本的基础上进行修改以达到要求
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)