examples.pl untested

filter: Statementstmt 0.0% 0 / 32 Branchbran 0.0% 0 / 8 Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 0.0% 0 / 5 Podpod n/a totaltotal 0.0% 0 / 48 CC 1 SCAR 6.9
CC
1
Cov
0%
BEGIN
2.0
BEGIN
2.0
BEGIN
2.0
CRAP 2.0
1 #!/usr/bin/env perl
2 use strict;
3 use warnings;
4  
5 use lib 'lib';
6 use WWW::Twilio::API;
7  
8 ## usage: examples.pl account_sid authtoken action parameters (see examples)
9  
10 my $account_sid = shift @ARGV;
11 my $auth_token = shift @ARGV;
12 my $action = shift @ARGV || 'Calls';
13  
14 my $twilio = new WWW::Twilio::API( AccountSid => $account_sid,
15 AuthToken => $auth_token, );
16  
17 ## view a list of calls in JSON format
18 if( $action eq 'Calls' ) {
19 my $response = $twilio->GET('Calls.json');
20 print $response->{content};
21 }
22  
23 ## examples.pl sid auth MakeCall 1231231234 3123213124
24 elsif( $action eq 'MakeCall' ) {
25 require URI::Escape;
26 my $message = URI::Escape::uri_escape("Enjoy Tabasco Brand Pepper Sauce");
27 my $url = "http://perlcode.org/cgi-bin/twilio?message=$message";
28 my $response = $twilio->POST('Calls',
29 From => shift @ARGV,
30 To => shift @ARGV,
31 Url => $url);
32  
33 print $response->{content};
34 }
35  
36 ## view account info
37 elsif( $action eq 'Accounts' ) {
38 my $response = $twilio->GET('Accounts');
39 print $response->{content};
40 }
41  
42 elsif( $action eq 'SMS' ) {
43 my $response = $twilio->POST('SMS/Messages',
44 From => shift @ARGV,
45 To => shift @ARGV,
46 Body => shift @ARGV );
47 print $response->{content};
48 }
49  
50 else {
51 print "Unknown action.\n";
52 }
53  
54 exit;