Created
July 31, 2013 16:12
-
-
Save callemall/6123464 to your computer and use it in GitHub Desktop.
This example creates a voice-only broadcast using the ExtCreateBroadcast function. In this case, the messageID parameter is left blank. Once the broadcast is created, a message will have to be recorded using the toll-free number and message recording ID returned by the function.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl -w | |
# SOAP client for CEA web service | |
use strict; | |
use SOAP::Lite; | |
# To turn on SOAP debugging use this | |
# ================================== | |
# use SOAP::Lite +trace => 'all'; | |
# ================================== | |
# | |
# You will need to put in your own values below | |
# | |
# --------------------------------------- | |
# Enter your username below | |
# --------------------------------------- | |
my $username = '99919991'; | |
# --------------------------------------- | |
# Enter your pin below | |
# --------------------------------------- | |
my $pin = '9991'; | |
# --------------------------------------- | |
# 1 = Announcement | |
# 2 = Survey | |
# 3 = SMS | |
# --------------------------------------- | |
my $broadcastType = '1'; | |
# --------------------------------------- | |
# 1=SavedList; | |
# 2=CSV; | |
# 3=Comma Delimited String of Phone Numbers | |
# --------------------------------------- | |
my $phoneNumberSource = '3'; | |
# --------------------------------------- | |
# Your descriptive broadcast name | |
# --------------------------------------- | |
my $broadcastName = 'My API Test'; | |
# --------------------------------------- | |
# MessageID to use for broadcast | |
# leave blank to receive 8XX number | |
# and message recording ID | |
# or specify TTSText to use our | |
# Text to Speech Engine | |
# --------------------------------------- | |
my $messageID = ''; | |
# --------------------------------------- | |
# caller id to use, if left blank | |
# will use default from your account | |
# --------------------------------------- | |
my $callerID = '9725551212'; | |
# --------------------------------------- | |
# PhoneNumberSource = 3, comma delimited | |
# list of numbers to call | |
# --------------------------------------- | |
my $commaDelimitedPhoneNumbers = '9725551313, 9725552323'; | |
my $PROXY = 'http://staging-API.call-em-all.com/webservices/ceaapi_v2.asmx'; | |
# For Production use this value for $PROXY | |
# ========================================================================= | |
# my $PROXY = 'http://API.call-em-all.com/webservices/ceaapi_v2.asmx'; | |
# ========================================================================= | |
my $soap = SOAP::Lite | |
-> uri('http://call-em-all.com') | |
-> on_action( sub { return '"http://call-em-all.com/ExtCreateBroadcast"' } ) | |
-> proxy($PROXY); | |
my $method = SOAP::Data->name('ExtCreateBroadcast') | |
->attr({xmlns => 'http://call-em-all.com/'}); | |
my $query = | |
SOAP::Data->name(myRequest => \SOAP::Data->value( | |
SOAP::Data->name(username => $username), | |
SOAP::Data->name(pin => $pin), | |
SOAP::Data->name(broadcastType => $broadcastType), | |
SOAP::Data->name(phoneNumberSource => $phoneNumberSource), | |
SOAP::Data->name(broadcastName => $broadcastName), | |
SOAP::Data->name(ListID => ''), | |
SOAP::Data->name(phoneNumberCSV => ''), | |
SOAP::Data->name(messageID => $messageID), | |
SOAP::Data->name(messageIDVM => ''), | |
SOAP::Data->name(launchDateTime => ''), | |
SOAP::Data->name(checkCallingWindow => '0'), | |
SOAP::Data->name(callerID => $callerID), | |
SOAP::Data->name(commaDelimitedPhoneNumbers => $commaDelimitedPhoneNumbers) | |
)); | |
my $result = $soap->call($method => $query); | |
unless ($result->fault) { | |
my @@crecords = $result->valueof('//ExtCreateBroadcastResponse/ExtCreateBroadcastResult'); | |
foreach my $pcval (@@crecords) { | |
print "\n\n\n"; | |
print "Results of Broadcast Creation\n"; | |
print "=====================================================\n"; | |
if(defined $pcval->{'errorCode'}) { print "ErrorCode = ".$pcval->{'errorCode'}."\n"; } | |
if(defined $pcval->{'errorMessage'}) { print "ErrorMessage = ".$pcval->{'errorMessage'}."\n"; } | |
if(defined $pcval->{'broadcastID'}) { print "BroadcastID = ".$pcval->{'broadcastID'}."\n"; } | |
if(defined $pcval->{'messageRecordingID'}) { print "MsgRecordingID = ".$pcval->{'messageRecordingID'}."\n"; } | |
if(defined $pcval->{'tollFreeNumber'}) { print "TollFreeNumber = ".$pcval->{'tollFreeNumber'}."\n"; } | |
if(defined $pcval->{'goodRecordCountOnFile'}) { print "GoodRecCount = ".$pcval->{'goodRecordCountOnFile'}."\n"; } | |
} | |
} else { | |
print join ', ', | |
$result->faultcode, | |
$result->faultstring, | |
$result->faultdetail; | |
} | |
sub scrub { | |
my $arg = shift; | |
if(! defined $$arg || $$arg eq '' || $$arg eq '(null)') { | |
$$arg = undef; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment