Perl Code Samples - Legacy


Sending SMS Messages
- Code Examples:

Send A Single Message

#!/usr/bin/perl
use LWP::UserAgent;
use HTTP::Request;
$ua = new LWP::UserAgent(keep_alive=>1);

$response = $ua->post('https://app.clubtexting.com/api/sending/',
 [user=>'username', pass=>'userpassword', phonenumber=>'2125551234', subject=>'test', message=>'test message', express=>1]);

print $response->content;

Send Multiple Messages

#!/usr/bin/perl
use LWP::UserAgent;
use HTTP::Request;

@messages = (
 ['3616885766', 'ex2test', 'test message'],
 ['3616885766', 'ex2test2', 'test message2'],
 ['3616885766', 'ex2test3', 'test message3']
);


$ua = new LWP::UserAgent(keep_alive=>1);

for my $msg (@messages) {
    $response = $ua->post('https://app.clubtexting.com/api/sending/', [user=>'exampleuser', pass=>'texting', phonenumber=>$msg->[0], subject=>$msg->[1], message=>$msg->[2], express=>1]);

    print $response->content;
}


Receiving Keyword Submissions
- Code Examples:

#!/usr/install/perl/bin/perl

use CGI qw/:standard/;

$message=param('Message');
$sender=param('PhoneNumber');

print "Content-type: text/html\n\n";

if ($sender>"")
{
    #Save incoming messages
    open FILE, ">>receivelog.txt";
    print FILE "$sender\n";
    close FILE;

    #Return a response SMS message
    $responsetext = "Thank you for the message!";
    print "{SMS:TEXT}{}{}{$sender}{$responsetext}";
}
else
{
    print "The Perl script is waiting for messages";
}


Check Credit Balance
- Code Examples:

#!/usr/bin/perl
use LWP::UserAgent;
use HTTP::Request;
$ua = new LWP::UserAgent(keep_alive=>1);

$response = $ua->post('https://app.clubtexting.com/api/credits/check/',
 [user=>'username', pass=>'userpassword']);

print $response->content;


Check Keyword Availability
- Code Examples:

#!/usr/bin/perl
use LWP::UserAgent;
use HTTP::Request;
$ua = new LWP::UserAgent(keep_alive=>1);

$response = $ua->post('https://app.clubtexting.com/api/keyword/check/',
 [user=>'username', pass=>'userpassword', keyword=>'userkeyword']);

print $response->content;


Buy More Credits
- Code Examples:

#!/usr/bin/perl
use LWP::UserAgent;
use HTTP::Request;
$ua = new LWP::UserAgent(keep_alive=>1);

$response = $ua->post('https://app.clubtexting.com/api/credits/buy/',
 [user=>'username', pass=>'userpassword', 'credits' => 5, 'firstname'=> 'firstname', 'lastname'=> 'lastname', 'address'=> 'address', 'city'=> 'newyork', 'state'=> 'ny', 'zip'=> '08902', 'country'=> 'usa', 'type'=> 'visa', 'ccnumber'=> 'rIhLJUiXl8M0JIcrelxH9A', 'cccode'=> '111', 'expm'=> '11', 'expy'=> '12']);

print $response->content;


Rent a Keyword:
- Code Examples

#!/usr/bin/perl
use LWP::UserAgent;
use HTTP::Request;
$ua = new LWP::UserAgent(keep_alive=>1);

$response = $ua->post('https://app.clubtexting.com/api/keyword/rent/',
 [user=>'username', pass=>'userpassword', 'keyword' => 'keywordtorent', 'firstname'=> 'firstname', 'lastname'=> 'lastname', 'address'=> 'address', 'city'=> 'newyork', 'state'=> 'ny', 'zip'=> '08902', 'country'=> 'usa', 'type'=> 'visa', 'ccnumber'=> 'rIhLJUiXl8M0JIcrelxH9A', 'cccode'=> '111', 'expm'=> '11', 'expy'=> '12']);

print $response->content;


Configure a Keyword
- Code Examples:

#!/usr/bin/perl
use LWP::UserAgent;
use HTTP::Request;
$ua = new LWP::UserAgent(keep_alive=>1);

$response = $ua->post('https://app.clubtexting.com/api/keyword/setup/',
 [user=>'username', pass=>'userpassword', 'keyword' => 'keywordtoconfigure', 'group'=> 'test', 'autoreply'=> 'autoreply', 'url'=> 'http://test.com/test']);

print $response->content;


Voice Broadcast
- Code Examples:


(Single Number)

#!/usr/bin/perl
use LWP::UserAgent;
use HTTP::Request;
$ua = new LWP::UserAgent(keep_alive=>1);

$response = $ua->post('https://app.clubtexting.com/api/voicemessages/',
 [user=>'username', pass=>'userpassword', 'phonenumbers' => '2125551234', 'soundsource'=> 'http://mydomain.com/sounds/voice.wav', 'callerid'=> '2127847840']);

print $response->content;

(An Array Of Numbers)

#!/usr/bin/perl
use LWP::UserAgent;
use HTTP::Request;
$ua = new LWP::UserAgent(keep_alive=>1);

$response = $ua->post('https://app.clubtexting.com/api/voicemessages/',
 [user=>'username', pass=>'userpassword', 'phonenumbers[]' => 'phone1', 'phonenumbers[]' => 'phone2', 'phonenumbers[]' => 'phone3', 'soundfile'=> '1236019718.wav', 'callerid'=> '2127847840']);

print $response->content;


Receiving Inbox Message Replies
- Code Examples:

#!/usr/install/perl/bin/perl

use CGI qw/:standard/;

$message=param('message');
$sender=param('from');

print "Content-type: text/html\n\n";

if ($sender>"")
{
    #Save incoming messages
    open FILE, ">>forwardlog.txt";
    print FILE "$sender\n";
    close FILE;
}


Carrier Lookup
- Code Examples:

#!/usr/bin/perl
use LWP::UserAgent;
use HTTP::Request;
$ua = new LWP::UserAgent(keep_alive=>1);

$response = $ua->post('https://app.clubtexting.com/api/lookup/',
 [user=>'username', pass=>'userpassword', phonenumber=>'2125551234']);

print $response->content;

Get started for free!

Sign up now