You are here

function twilio_receive_voice in Twilio 7

Callback for incoming voice calls.

1 string reference to 'twilio_receive_voice'
twilio_menu in ./twilio.module
Implements hook_menu().

File

./twilio.module, line 346
Twilio module

Code

function twilio_receive_voice() {
  if (!empty($_REQUEST['From']) && twilio_command('validate', array(
    'type' => 'voice',
  ))) {
    $number = check_plain(str_replace('+1', '', $_REQUEST['From']));
    $number_twilio = !empty($_REQUEST['To']) ? check_plain(str_replace('+', '', $_REQUEST['To'])) : '';
    $options = array();
    if (!empty($_REQUEST['To'])) {
      $options['receiver'] = check_plain($_REQUEST['To']);
    }
    watchdog('Twilio', 'A voice call from @number was received.', array(
      '@number' => $number,
    ));
    twilio_voice_incoming($number, $number_twilio, $options);
  }
}