-
Notifications
You must be signed in to change notification settings - Fork 3
/
tropo_whisper.php
50 lines (45 loc) · 1.47 KB
/
tropo_whisper.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php
function choiceFCN($event) {
global $session;
if ($event->value == "yes") {
conference("1337");
}
else {
$curl_handle=curl_init();
curl_setopt($curl_handle,CURLOPT_URL,'https://api.tropo.com/1.0/sessions/'.$session.'/signals?action=signal&value=exit');
curl_setopt($curl_handle,CURLOPT_CONNECTTIMEOUT,2);
curl_exec($curl_handle);
curl_close($curl_handle);
say("You declined, disconnecting");
}
}
function badChoiceFCN($event) {
say("I’m sorry, I didn’t understand that. You can say yes or no");
}
if ($currentCall->callerID == null) {
call("+14075550100");
ask("Do you want to connect to ".$caller."?", array(
"choices" => "yes, no",
"timeout" => 10.0,
"attempts" => 3,
"onChoice" => "choiceFCN",
"onBadChoice" => "badChoiceFCN"
)
);
}
else {
$token = 'your_token';
$callerID = $currentCall->callerID;
$sessionID = $currentCall->sessionId;
$curl_handle=curl_init();
curl_setopt($curl_handle,CURLOPT_URL,'http://api.tropo.com/1.0/sessions?action=create&token='.$token.'&caller='.$callerID.'&session='.$sessionID);
curl_setopt($curl_handle,CURLOPT_CONNECTTIMEOUT,2);
curl_exec($curl_handle);
curl_close($curl_handle);
say("please hold while we connect your call");
conference("1337", array(
"allowSignals" => "exit"
));
say("The recipient declined the call. Goodbye.");
}
?>