Skip to content

Instantly share code, notes, and snippets.

@callemall
Created July 31, 2013 16:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save callemall/6123404 to your computer and use it in GitHub Desktop.
Save callemall/6123404 to your computer and use it in GitHub Desktop.
Using the ExtCreateBroadcast function, this example launches a text-only broadcast to a set of comma delimited phone numbers. Recipients must be able to receive texts on their phone.
#!/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
#
# ---------------------------------------
my $username = '999999111';
my $pin = '9991';
# ---------------------------------------
# 1 = Announcement
# 2 = Survey
# 3 = SMS
# ---------------------------------------
my $broadcastType = '3';
# ---------------------------------------
# 1=SavedList;
# 2=CSV;
# 3=Comma Delimited String of Phone Numbers
# ---------------------------------------
my $phoneNumberSource = '3';
my $broadcastName = 'My SMS Test';
my $commaDelimitedPhoneNumbers = '9725551313, 9726661313';
my $smsMsg = 'Hello this is a test message! Have a great day';
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(commaDelimitedPhoneNumbers => $commaDelimitedPhoneNumbers),
SOAP::Data->name(smsMsg => $smsMsg)
));
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 "SMSBroadcastID = ".$pcval->{'SMSbroadcastID'}."\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