#!/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 find out the # ## current status of an call requested with that service. Used in conjunction # ## with makeCall.pl and cancelCall.pl. # ## # ## Example usage (when the requestID of the call is "12345": # ## getStatus.pl 12345 -c production # ## # ## 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"; # 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 my $requestID = ''; #-----------------------------------------------------------# # main -- Get the status for a specific Outbound call # #-----------------------------------------------------------# processArgs(@ARGV); if ($ARGV[0] == '') { usage("You must pass in a RequestID."); } my $h = getOutboundStatus($ARGV[0]); my $key=''; print "The status for outbound call request #", $ARGV[0], " is:\n"; foreach $key (keys %$h) { print " $key='$$h{$key}'\n"; } exit(0); #-------------------------------------------------------------# # Supporting functions below this point # #-------------------------------------------------------------# sub usage { print "ERROR: $_[0]\n\n"; print "USAGE: getStatus.pl requestID [-c ]\n"; print "\n"; print " When an Outbound call is made, it is assigned a RequestID.\n"; print " You can pass that requestID into this function, to get information\n"; print " on the progress of the outbound call.\n"; print "\n"; print " If a customer is not specified, 'production' is assumed.\n"; print "\n"; exit(1); } # ------------------------------------------------------------------------ sub processArgs { $requestID = $ARGV[0]; shift(@_); # pull off the requestID while ($#_ >= 0) { if ($_[0] eq '-c') { shift(@_); $customer = $_[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"); } } #----------------------------------------------------------------# # getOutboundStatus(id) # # # # input: id (int) # # output: status info # # errors: if there is a SOAP fault, or a transport error, # # the perl process will die with an error message. # #----------------------------------------------------------------# sub getOutboundStatus { my ($id)= @_; $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, # passed in via the SOAP header, as per the W3C. my $head = SOAP::Header->name( platformServicesSessionID => $myAccessKey); # If there's a problem, print out fault or transport info and die. my $res1 = $outboundService->getOutBoundDetails( $head, SOAP::Data->type('long')->name(requestID => $id), ); return $res1->result(); }