/samples/recordingdemo.php
PHP | 38 lines | 28 code | 4 blank | 6 comment | 6 complexity | 1150520e08e995fe9ea2a2a58edc6bb9 MD5 | raw file
Possible License(s): MIT
1<?php 2require_once 'tropo.class.php'; 3 4// KLogger is a logging class from 5// http://codefury.net/projects/klogger/ 6require_once 'KLogger.php'; 7 8$log = new KLogger ( "log.txt" , KLogger::INFO ); 9 10// Does the ?record query string exist? If not, this is an incoming call. 11if (!array_key_exists('record', $_GET)) { 12 $tropo = new Tropo(); 13 $tropo->record(array( 14 'say' => 'Leave your message at the beep.', 15 'url' => getself() . '?record', // append ?record to the URL 16 )); 17 print $tropo; 18} else { 19 // Change this path to match the location on your server where you want 20 // the file to be saved. 21 $target_path = 'path/to/recording/' . $_FILES['filename']['name']; 22 if(move_uploaded_file($_FILES['filename']['tmp_name'], $target_path)) { 23 $log->LogInfo("$target_path [{$_FILES['filename']['size']} bytes] was saved"); 24 } else { 25 $log->LogError("$target_path could not be saved."); 26 } 27} 28 29// Simple function to get the full URL of the current script. 30function getself() { 31 $pageURL = 'http'; 32 $url = ($_SERVER["HTTPS"] == "on") ? 'https' : 'http'; 33 $url .= "://" . $_SERVER["SERVER_NAME"]; 34 $url .= ($_SERVER["SERVER_PORT"] != "80") ? ':'. $_SERVER["SERVER_PORT"] : ''; 35 $url .= $_SERVER["REQUEST_URI"]; 36 return $url; 37} 38?>