line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Voicent;
|
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
67062
|
use 5.008006;
|
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
41
|
|
4
|
1
|
|
|
1
|
|
6
|
use strict;
|
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
37
|
|
5
|
1
|
|
|
1
|
|
5
|
use warnings;
|
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
42
|
|
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
2493
|
use LWP::UserAgent;
|
|
1
|
|
|
|
|
83307
|
|
|
1
|
|
|
|
|
47
|
|
8
|
1
|
|
|
1
|
|
1593
|
use HTTP::Request::Common;
|
|
1
|
|
|
|
|
2689
|
|
|
1
|
|
|
|
|
107
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
require Exporter;
|
11
|
1
|
|
|
1
|
|
1280
|
use AutoLoader qw(AUTOLOAD);
|
|
1
|
|
|
|
|
2217
|
|
|
1
|
|
|
|
|
7
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our @ISA = qw(Exporter);
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
our @EXPORT = qw(
|
16
|
|
|
|
|
|
|
host
|
17
|
|
|
|
|
|
|
port
|
18
|
|
|
|
|
|
|
call_text
|
19
|
|
|
|
|
|
|
call_audio
|
20
|
|
|
|
|
|
|
call_status
|
21
|
|
|
|
|
|
|
call_remove
|
22
|
|
|
|
|
|
|
call_till_confirm
|
23
|
|
|
|
|
|
|
);
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
our %EXPORT_TAGS = ( 'all' => [ @EXPORT ] );
|
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
|
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
our $VERSION = '1.1';
|
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
# change to the host name for your installation
|
32
|
|
|
|
|
|
|
$Voicent::host = "localhost";
|
33
|
|
|
|
|
|
|
$Voicent::port = 8155;
|
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub _call_now {
|
36
|
0
|
|
|
0
|
|
|
my %params = %{$_[0]};
|
|
0
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
|
38
|
0
|
|
|
|
|
|
my $ua = LWP::UserAgent->new(agent => 'Mozilla/4.0');
|
39
|
|
|
|
|
|
|
|
40
|
0
|
|
|
|
|
|
my $url = 'http://' . $Voicent::host . ':' . $Voicent::port . '/ocall/callreqHandler.jsp';
|
41
|
0
|
|
|
|
|
|
my $resp = $ua->request(POST $url,
|
42
|
|
|
|
|
|
|
Content_Type => 'application/x-www-form-urlencoded',
|
43
|
|
|
|
|
|
|
Content => [ %params ]
|
44
|
|
|
|
|
|
|
);
|
45
|
|
|
|
|
|
|
|
46
|
0
|
0
|
|
|
|
|
unless ($resp->is_success) {
|
47
|
0
|
|
|
|
|
|
print "Error sending call request to Voicent Gateway";
|
48
|
0
|
|
|
|
|
|
return "";
|
49
|
|
|
|
|
|
|
}
|
50
|
|
|
|
|
|
|
|
51
|
0
|
|
|
|
|
|
my $result = $resp->content();
|
52
|
0
|
|
|
|
|
|
my $pos = index ($result, '[ReqId=');
|
53
|
0
|
0
|
|
|
|
|
unless ($pos >=0) {
|
54
|
0
|
|
|
|
|
|
print "Error getting call request id from Voicent Gateway";
|
55
|
0
|
|
|
|
|
|
return "";
|
56
|
|
|
|
|
|
|
}
|
57
|
0
|
|
|
|
|
|
$pos = $pos + 7;
|
58
|
0
|
|
|
|
|
|
my $pos2 = index ($result, ']', $pos);
|
59
|
0
|
|
|
|
|
|
my $reqId = substr($result, $pos, $pos2 - $pos);
|
60
|
|
|
|
|
|
|
|
61
|
0
|
|
|
|
|
|
return $reqId;
|
62
|
|
|
|
|
|
|
}
|
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub call_text {
|
65
|
0
|
|
|
0
|
1
|
|
my ($phoneno, $textmsg, $selfdelete) = @_;
|
66
|
|
|
|
|
|
|
|
67
|
0
|
|
|
|
|
|
my %params = ();
|
68
|
0
|
|
|
|
|
|
$params{'info'} = 'call ' . $phoneno;
|
69
|
0
|
|
|
|
|
|
$params{'phoneno'} = $phoneno;
|
70
|
0
|
|
|
|
|
|
$params{'firstocc'} = '10';
|
71
|
0
|
|
|
|
|
|
$params{'txt'} = $textmsg;
|
72
|
0
|
|
|
|
|
|
$params{'selfdelete'} = $selfdelete;
|
73
|
|
|
|
|
|
|
|
74
|
0
|
|
|
|
|
|
return _call_now(\%params);
|
75
|
|
|
|
|
|
|
}
|
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub call_audio {
|
78
|
0
|
|
|
0
|
1
|
|
my ($phoneno, $audiofile, $selfdelete) = @_;
|
79
|
|
|
|
|
|
|
|
80
|
0
|
|
|
|
|
|
my %params = ();
|
81
|
0
|
|
|
|
|
|
$params{'info'} = 'call ' . $phoneno;
|
82
|
0
|
|
|
|
|
|
$params{'phoneno'} = $phoneno;
|
83
|
0
|
|
|
|
|
|
$params{'firstocc'} = '10';
|
84
|
0
|
|
|
|
|
|
$params{'audiofile'} = $audiofile;
|
85
|
0
|
|
|
|
|
|
$params{'selfdelete'} = $selfdelete;
|
86
|
|
|
|
|
|
|
|
87
|
0
|
|
|
|
|
|
return _call_now(\%params);
|
88
|
|
|
|
|
|
|
}
|
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
sub call_status {
|
91
|
0
|
|
|
0
|
1
|
|
my ($reqId) = @_;
|
92
|
|
|
|
|
|
|
|
93
|
0
|
|
|
|
|
|
my $url = 'http://' . $Voicent::host . ':' . $Voicent::port . '/ocall/callstatusHandler.jsp';
|
94
|
0
|
|
|
|
|
|
$url = $url . '?reqid=' . $reqId;
|
95
|
|
|
|
|
|
|
|
96
|
0
|
|
|
|
|
|
my $ua = LWP::UserAgent->new(agent => 'Mozilla/4.0');
|
97
|
|
|
|
|
|
|
|
98
|
0
|
|
|
|
|
|
my $resp = $ua->request(GET $url);
|
99
|
|
|
|
|
|
|
|
100
|
0
|
0
|
|
|
|
|
unless ($resp->is_success) {
|
101
|
0
|
|
|
|
|
|
print "Error sending call request to Voicent Gateway";
|
102
|
0
|
|
|
|
|
|
return "";
|
103
|
|
|
|
|
|
|
}
|
104
|
|
|
|
|
|
|
|
105
|
0
|
|
|
|
|
|
my $result = $resp->content();
|
106
|
|
|
|
|
|
|
|
107
|
0
|
0
|
|
|
|
|
if ($result =~ m#\Q^made^\E#) { return "Call Made"; }
|
|
0
|
|
|
|
|
|
|
108
|
0
|
0
|
|
|
|
|
if ($result =~ m#\Q^failed^\E#) { return "Call Failed"; }
|
|
0
|
|
|
|
|
|
|
109
|
0
|
|
|
|
|
|
print "";
|
110
|
|
|
|
|
|
|
}
|
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
sub call_remove {
|
113
|
0
|
|
|
0
|
1
|
|
my ($reqId) = @_;
|
114
|
|
|
|
|
|
|
|
115
|
0
|
|
|
|
|
|
my $url = 'http://' . $Voicent::host . ':' . $Voicent::port . '/ocall/callremoveHandler.jsp';
|
116
|
0
|
|
|
|
|
|
$url = $url . '?reqid=' . $reqId;
|
117
|
|
|
|
|
|
|
|
118
|
0
|
|
|
|
|
|
my $ua = LWP::UserAgent->new(agent => 'Mozilla/4.0');
|
119
|
|
|
|
|
|
|
|
120
|
0
|
|
|
|
|
|
my $resp = $ua->request(GET $url);
|
121
|
|
|
|
|
|
|
|
122
|
0
|
0
|
|
|
|
|
unless ($resp->is_success) {
|
123
|
0
|
|
|
|
|
|
print "Error sending call request to Voicent Gateway";
|
124
|
0
|
|
|
|
|
|
return "";
|
125
|
|
|
|
|
|
|
}
|
126
|
|
|
|
|
|
|
}
|
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
# voc file must reside on the same machine as the gateway
|
129
|
|
|
|
|
|
|
# this function can be achieved using command line interface
|
130
|
|
|
|
|
|
|
# vcast.exe -startnow -confirmcode [code] -wavfile [wavfile]
|
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
sub call_till_confirm {
|
133
|
0
|
|
|
0
|
1
|
|
my ($vcast, $vocfile, $confirmcode, $wavfile) = @_;
|
134
|
|
|
|
|
|
|
|
135
|
0
|
|
|
|
|
|
my %params = ();
|
136
|
0
|
|
|
|
|
|
$params{'info'} = 'call till concel';
|
137
|
0
|
|
|
|
|
|
$params{'phoneno'} = '0000000';
|
138
|
0
|
|
|
|
|
|
$params{'firstocc'} = '10';
|
139
|
0
|
|
|
|
|
|
$params{'startexec'} = $vcast;
|
140
|
0
|
|
|
|
|
|
$params{'selfdelete'} = '1';
|
141
|
0
|
|
|
|
|
|
$params{'cmdline'} = '"' . $vocfile . '" -startnow -confirmcode ' . $confirmcode
|
142
|
|
|
|
|
|
|
. ' -wavfile "' . $wavfile . '"';
|
143
|
|
|
|
|
|
|
|
144
|
0
|
|
|
|
|
|
return _call_now(\%params);
|
145
|
|
|
|
|
|
|
}
|
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
# samples
|
148
|
|
|
|
|
|
|
# $reqId = call_text(1234567, 'hello, how are you', 0);
|
149
|
|
|
|
|
|
|
# $reqId = call_audio(1234567, 'C:\temp\welcome.wav', 0);
|
150
|
|
|
|
|
|
|
# $status = call_status($reqId);
|
151
|
|
|
|
|
|
|
# call_remove($reqId);
|
152
|
|
|
|
|
|
|
# call_till_confirm('c:\Program Files\Voicent\BroadcastByPhone\bin\vcast.exe', 'c:\temp\tt1.voc', '1234', 'c:\temp\welcome.wav');
|
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
1;
|
156
|
|
|
|
|
|
|
__END__
|