#!/usr/bin/perl ################################################################################## ## BeVocal Sample Code # ## (C) Copyright BeVocal, Inc. 2003, All rights reserved. # ## # ## This Sample Code is provided for your reference purposes, and carries no # ## warranty whatsoever. Use of this code is restricted to use in connection # ## with the BeVocal Cafe developer's program. # ## # ## BeVocal disclaims and excludes any and all warranties of merchantability, # ## title and fitness for a particular purpose. BeVocal does not warrant that the # ## software will satisfy your requirements, or that the software is without # ## defect or error. You are using the software at your own risk. # ## # ## This sample accesses the Outbound Notification Service to request a call. # ## Used in conjunction with cancelCall.pl and getStatus.pl. # ## # ## Example usage: # ## makeCall.pl 6506411465 -c production -u http://www.myserver.com/myApp.vxml # ## # ## This script uses a store for security keys. See its documentation in # ## http://cafe.bevocal.com/resources/voicexml_samples/keyRing.pl # ################################################################################## #use SOAP::Lite +trace => 'debug', xmlschema => 2001; use SOAP::Lite xmlschema => 2001; use strict; require "../keyRing.pl"; # access keys are found here. # Define global variables my $soapOutboundURL = 'OutboundNotificationService_v1/services/OutboundNotificationService_v1'; my $soapURL = ''; my $accessSystem = ''; my $orgId = ''; my $appId = ''; my $soapServer = ''; my $myAccessKey = ''; my $customer = "production"; # default to using Production key my $phone = ''; my $vxmlURL = 'http://www.zenstarstudio.com/bevocal/cache/test1.vxml'; # The callingParty field is currently required. my $callingParty = '4085551212'; #-------------------------------------------------------------# # initiateSimpleOutboundCall(phone) # # # # input: phone number (string) # # URL (string) # # output: an Outbound call is initiated # # errors: if there is a SOAP fault, or a transport error, # # the perl process will die with an error message. # #-------------------------------------------------------------# sub initiateSimpleOutboundCall { my ($phone, $url)= @_; # construct URI of the SOAP Outbound Service $soapURL = "http://$soapServer/$soapOutboundURL"; # Setup a pointer to the Outbound Service my $outboundService = SOAP::Lite ->proxy($soapURL) ->uri('http://www.bevocal.com/soap/services/') ->on_fault( sub { my($outboundService, $res) = @_; die ref $res ? $res->faultstring : $outboundService->transport->status, "\n"; }); # To call this service, we need an Access Key, # and it must be passed in via the SOAP header, as per the W3C. my $head = SOAP::Header->name( platformServicesSessionID => $myAccessKey); # Here's an example of the time format used. my $time = "2003-05-13T23:42:00Z"; # Call the Outbound Service. # If there's a problem, print out fault or transport info and die. my $res1 = $outboundService->submitOutboundRequest( $head, SOAP::Data->type('string')->name(calledParty => $phone), SOAP::Data->type('string')->name(callingParty => $callingParty), SOAP::Data->type('string')->name(initialURL => $url), SOAP::Data->type('string')->name(replyURI => "mailto:mpogue\@bevocal.com"), # SOAP::Data->type('int')->name(busyRetries => 2), # SOAP::Data->type('int')->name(busyRetryInterval => 60), # SOAP::Data->type('int')->name(noAnswerRetries => 2), # SOAP::Data->type('int')->name(noAnswerRetryInterval => 60), # If you don't need to specify the time, comment out this line. SOAP::Data->type('dateTime')->name(requestTime => $time) ); return $res1->result(); } # ----------------------------------------------------------------------------------- sub usage { print "ERROR: $_[0]\n\n"; print "USAGE: makeCall.pl [-u URL] [-c ]\n"; print "\n"; print " Initiates an outbound call to a phone number.\n"; print " If is not specified, 'production' will be used.\n"; print " The URL used is specified with the -u switch.\n"; exit(1); } # ------------------------------------------------------------------- sub processArgs { shift(@_); # phone number while ($#_ >= 0) { if ($_[0] eq '-c') { shift(@_); $customer = $_[0]; } elsif ($_[0] eq '-u') { shift(@_); $vxmlURL = $_[0]; } else { usage("Incorrect parameter given: '" . $_[0] . "'"); } shift(@_); } # get the AccessKey, based on the customer specified on the command line ($accessSystem, $orgId, $appId, $soapServer, $myAccessKey) = getProviderData($customer); if ($accessSystem eq "NoProviderFound") { usage("No valid SOAP Provider given"); } $phone = $ARGV[0]; if ($phone eq "") { usage("You must provide a phone number to call."); } } #-------------------------------------------------------------# # main -- initiate the call, and print out the return code # #-------------------------------------------------------------# processArgs(@ARGV); print "An outbound call is being generated to ",$phone,"\nfrom ",$soapServer,".\n"; print "This call's ID is: ", initiateSimpleOutboundCall( $phone, $vxmlURL), ".\n";