PHP Code Samples - Legacy


Sending SMS Messages
- Code Examples:

Single Message

<?php
$ch=curl_init('https://app.clubtexting.com/api/sending');
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch,CURLOPT_POST,1);
curl_setopt($ch,CURLOPT_POSTFIELDS,"user=username&pass=userpassword&phonenumber=2125551234&subject=test&message=test message&express=1");
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
$data = curl_exec($ch);
print($data); /* result of API call*/
?>

Multiple Messages

<?php
 
/* The below code snippet is a sample and not functional.  Its purpose is to illustrate how to send multiple requests to our service using one connection */
 
$ch = curl_init('https://app.clubtexting.com/api/sending');
 
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
 
foreach ($messages as $message) {
    $post = "user=username&pass=userpassword&phonenumber=" . $message['phone'] . "&subject=" . $message['subject'] . "&message=" . $message['message'] . "&express=1";
    curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
    $data = curl_exec($ch);
}
 
curl_close($ch);
 
?>


Receiving Keyword Submissions
- Code Examples:

<?php
 $sender = $_GET['PhoneNumber'];
 $message = $_GET['Message'];
  if ($sender!='') {
     // Save incoming messages
     $fp = fopen("receivelog.txt","a");
     fputs($fp,"$sender $message\n");
     fclose($fp);

     // Return a response SMS message
     $responsetext = "Thank you for the message!";
     echo "{SMS:TEXT}{}{}{".$sender."}{".$responsetext."}";
  } else {
     echo "The PHP script is waiting for messages";
  }
?>


Check Credit Balance
- Code Examples:

<?php
$ch = curl_init('https://app.clubtexting.com/api/credits/check');
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch,CURLOPT_POST,1);
curl_setopt($ch,CURLOPT_POSTFIELDS,"user=username&pass=userpassword");
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
$data = curl_exec($ch);
print($data); /* result of API call*/
?>


Check Keyword Availability
- Code Examples:

<?php
$ch = curl_init('https://app.clubtexting.com/api/keyword/check');
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch,CURLOPT_POST,1);
curl_setopt($ch,CURLOPT_POSTFIELDS,"user=username&pass=userpassword&keyword=
userkeyword");
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
$data = curl_exec($ch);
print($data); /* result of API call*/
?>


Buy More Credits
- Code Examples:

<?php
$ch = curl_init('https://app.clubtexting.com/api/credits/buy');
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch,CURLOPT_POST,1);
curl_setopt($ch,CURLOPT_POSTFIELDS,"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");
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
$data = curl_exec($ch);
print($data); /* result of API call*/
?>


Rent a Keyword:
- Code Examples

<?php
$ch = curl_init('https://app.clubtexting.com/api/keyword/rent');
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch,CURLOPT_POST,1);
curl_setopt($ch,CURLOPT_POSTFIELDS,"user=username&pass=userpassword&keyword=keywordtorent&firstname=firstname&lastname=lastname&address=address&city=newyork&state=ny&zip=08902&country=usa&type=visa&ccnumber=rIhLJUiXl8M0JIcrelxH9A&expm=11&expy=2012");
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
$data = curl_exec($ch);
print($data); /* result of API call*/
?>


Configure a Keyword
- Code Examples:

<?php
$ch = curl_init('https://app.clubtexting.com/api/keyword/setup/');
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch,CURLOPT_POST,1);
curl_setopt($ch,CURLOPT_POSTFIELDS,"user=username&pass=userpassword&keyword=keywordtoconfigure&group=test&autoreply=autoreply&url=http://test.com/test");
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
$data = curl_exec($ch);
print($data); /* result of API call*/
?>

Voice Broadcast - Code Examples:


(Single Number)

<?php
$ch = curl_init('https://app.clubtexting.com/api/voicemessages/');
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch,CURLOPT_POSTFIELDS,"user=username&pass=password&phonenumbers=2125551234&soundsource=http://mydomain.com/sounds/voice.wav
&callerid=2127847840");
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
$data = curl_exec($ch);
print($data); /* result of API call*/
?>

(Single Number 2nd Example)

<?php
$ch = curl_init('https://app.clubtexting.com/api/voicemessages/');
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch,CURLOPT_POSTFIELDS,"user=username&pass=password&phonenumbers=2125551234&soundfile=1236019718.wav
&callerid=2127847840");
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
$data = curl_exec($ch);
print($data); /* result of API call*/
?>

(An Array Of Numbers)

<?php
$ch = curl_init('https://app.clubtexting.com/api/voicemessages/');
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch,CURLOPT_POSTFIELDS,"user=username&pass=password&phonenumbers[]=phone1&phonenumbers[]=phone2&phonenumbers[]=phone3&soundfile=1236019718.wav&callerid=2127847840");
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
$data = curl_exec($ch);
print($data); /* result of API call*/
?>


Receiving Inbox Message Replies
- Code Examples:

<?php
 $sender = $_GET['from'];
 $message = $_GET['message'];
  if ($sender!='') {
     // Save incoming messages
     $fp = fopen("forwardlog.txt","a");
     fputs($fp,"$sender $message");
     fclose($fp);
	}    
?>


Carrier Lookup
- Code Examples:

<?php
$ch=curl_init('https://app.clubtexting.com/api/lookup');
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch,CURLOPT_POST,1);
curl_setopt($ch,CURLOPT_POSTFIELDS,"user=username&pass=userpassword&phonenumber=
2125551234");
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
$data = curl_exec($ch);
print(); /* result of API call*/
?>

Get started for free!

Sign up now