Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
This example invites a phone number to join the text messaging group identified by the keyword "RAMBLES". The SendOptInvitation function is used for this purpose.
#!/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 = '999999111';
# ---------------------------------------
# Enter your pin below
# ---------------------------------------
my $pin = '9991';
my $firstName = "PersonTo";
my $lastName = "Invite";
my $invitePhonenumber = "9725551212";
my $keyword = "RAMBLES";
my $message = "Follow instructs to join my group ";
my $YisOK = "0";
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/SendOptInvitation"' } )
-> proxy($PROXY);
my $method = SOAP::Data->name('SendOptInvitation')
->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(firstname => $firstName),
SOAP::Data->name(lastname => $lastName),
SOAP::Data->name(invitePhonenumber => $invitePhonenumber),
SOAP::Data->name(keyword => $keyword),
SOAP::Data->name(message => $message),
SOAP::Data->name(YisOK => $YisOK)
));
my $result = $soap->call($method => $query);
unless ($result->fault) {
my @@crecords = $result->valueof('//SendOptInvitationResponse/SendOptInvitationResult');
foreach my $pcval (@@crecords) {
print "\n\n\n";
print "Results of Send opt-In Invitation Request\n";
print "=====================================================\n";
if(defined $pcval->{'errorCode'}) { print "ErrorCode = ".$pcval->{'errorCode'}."\n"; }
if(defined $pcval->{'errorMessage'}) { print "ErrorMessage = ".$pcval->{'errorMessage'}."\n"; }
if(defined $pcval->{'response'}) { print "Response = ".$pcval->{'response'}."\n"; }
if(defined $pcval->{'message'}) { print "Message = ".$pcval->{'message'}."\n"; }
if(defined $pcval->{'keyword'}) { print "Keyword = ".$pcval->{'keyword'}."\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
You can’t perform that action at this time.