Пример #1
0
<?php

$ci =& get_instance();
/* Get the body of the SMS message */
$body = isset($_REQUEST['Body']) ? trim($ci->input->get_post('Body')) : null;
$body = strtolower($body);
$prompt = AppletInstance::getValue('prompt');
$keys = AppletInstance::getValue('keys[]');
$responses = AppletInstance::getValue('responses[]');
$menu_items = AppletInstance::assocKeyValueCombine($keys, $responses, 'strtolower');
$response = new TwimlResponse();
/* Display the menu item if we found a match - case insensitive */
if (array_key_exists($body, $menu_items) && !empty($menu_items[$body])) {
    $response_text = $menu_items[$body];
} else {
    /* Display the prompt if incorrect */
    $response_text = $prompt;
}
$response->sms($response_text);
$response->Respond();
Пример #2
0
            $twiml->addSay("Connecting you to " . $roommate['name'], array("voice" => $config['voice']));
            $twiml->addDial($roommate['number']);
        }
        // not a valid input, send back to the menu
        $twiml->addRedirect($config['filename']);
        break;
    case "secret":
        // handle the secret code entry
        if ($config['secret'] && $_REQUEST['Digits'] == $config['secret']) {
            // secret code matches, buzz the caller in
            $twiml->addSay("Buzzing you in now.", array("voice" => $config['voice']));
            $twiml->addPlay("http://www.dialabc.com/i/cache/dtmfgen/wavpcm8.300/" . $config['gate_code'] . ".wav");
        }
        // either the feature is disabled or they didn't enter the proper code, send back to the menu
        $twiml->addRedirect($config['filename']);
        break;
    default:
        // provide the main menu
        $twiml->addPause(array("length" => "2"));
        $gather = $twiml->addGather(array("action" => $config['filename'] . "?page=gather", "numDigits" => "1", "method" => "POST"));
        $gather->addSay($config['greeting'], array("voice" => $config['voice']));
        // loop through each roommate for the menu
        foreach ($config['roommates'] as $num => $roommate) {
            $gather->addPause(array("length" => "1"));
            $gather->addSay("For " . $roommate['name'] . ", press " . ($num + 1) . ".", array("voice" => $config['voice']));
        }
        break;
}
// output all of the XML generated
$twiml->Respond();