コード例 #1
0
function printTropo()
{
    $post = getself() . '?action=record';
    $code = <<<EOD
  <?php
  call('+' . \$from);
  sleep(2); // Pause a moment after they answer.
  say('One moment, connecting you now.');
  transfer({$number}, array(
    'playvalue' => 'https://raw.githubusercontent.com/tropo/pre-recorded_audio_library/master/Telephone/ring.wav',
    'playrepeat' => '10',
    'onTimeout' => 'handleTimeout'
    ));

  function handleTimeout() {
    record('Sorry, but I am not available right now. Please leave a message.', array(
      'beep' => true,
      'maxTime' => 45,
      'recordURI' => {$post}
      ))
  }
  ?>
EOD;
    return $code;
}
コード例 #2
0
ファイル: demo.php プロジェクト: hack4reno/hack4reno2011
<?php

// Set your CloudFiles username and password here
$user = '';
$apikey = '';
$ch = curl_init();
curl_setopt($ch, CURLOPT_USERPWD, "{$user}:{$apikey}");
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_VERBOSE, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_URL, str_replace('demo.php', 'poster.php', getself()) . '?container=demo');
curl_setopt($ch, CURLOPT_POST, true);
$post = array("filename" => '@' . dirname(__FILE__) . '/demo.jpg');
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
$response = curl_exec($ch);
print_r($response);
function getself()
{
    $pageURL = 'http';
    $url = $_SERVER["HTTPS"] == "on" ? 'https' : 'http';
    $url .= "://" . $_SERVER["SERVER_NAME"];
    $url .= $_SERVER["SERVER_PORT"] != "80" ? ':' . $_SERVER["SERVER_PORT"] : '';
    $url .= $_SERVER["REQUEST_URI"];
    return $url;
}
コード例 #3
0
<?php

require_once 'tropo.class.php';
// KLogger is a logging class from
// http://codefury.net/projects/klogger/
require_once 'KLogger.php';
$log = new KLogger("log.txt", KLogger::INFO);
// Does the ?record query string exist? If not, this is an incoming call.
if (!array_key_exists('record', $_GET)) {
    $tropo = new Tropo();
    $tropo->record(array('say' => 'Leave your message at the beep.', 'url' => getself() . '?record'));
    print $tropo;
} else {
    // Change this path to match the location on your server where you want
    // the file to be saved.
    $target_path = 'path/to/recording/' . $_FILES['filename']['name'];
    if (move_uploaded_file($_FILES['filename']['tmp_name'], $target_path)) {
        $log->LogInfo("{$target_path} [{$_FILES['filename']['size']} bytes] was saved");
    } else {
        $log->LogError("{$target_path} could not be saved.");
    }
}
// Simple function to get the full URL of the current script.
function getself()
{
    $pageURL = 'http';
    $url = $_SERVER["HTTPS"] == "on" ? 'https' : 'http';
    $url .= "://" . $_SERVER["SERVER_NAME"];
    $url .= $_SERVER["SERVER_PORT"] != "80" ? ':' . $_SERVER["SERVER_PORT"] : '';
    $url .= $_SERVER["REQUEST_URI"];
    return $url;