Mass Text Message Marketing by Club Texting
SMS Marketing Specialist: (212) 601-9383 | Pricing | FAQ | Contact | Login
  • Feature Tour
  • Products
    • Bulk SMS Marketing Service
    • Text Messaging API
    • Other Services
    • Carrier Lookup API
    • Dedicated Short Codes
    • Short Code Services
  • Solutions
    • Ad Agencies
    • Events
    • Higher Education
    • Media
    • Magazines
    • Nightlife
    • Political Campaigns
    • Radio
    • Real Estate
    • Religious Groups
    • Restaurants
    • Retail
    • Social & Non Profits
  • Try For Free
  • Developer Center
  • SMS API Home
  • REST API Docs
  • Incoming API Docs
  • Carrier Lookup API Docs
  • Legacy HTTP API Docs
  • Legacy HTTP API FAQs
  • REST API Code Samples
  • C#
  • Java
  • Perl
  • PHP
  • Python
  • Ruby
  • Legacy HTTP API Code Samples
  • C#
  • Java
  • Perl
  • PHP
  • Python
  • Ruby

PHP Code Examples For The HTTP APIs


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*/
?>

Find Club Texting On Facebook Follow Club Texting On Twitter Find Club Texting On Google Plus The Latest Club Texting TweetFrom The Blog: Mobile Marketing That's Mobile - Engage With Brands In A Taxi http://t.co/mOaNo2pOrf1:47 PM May 15th

  • About Club Texting
  • Carrier Coverage
  • Case Studies
  • Client Testimonials
  • Getting Started Guides
  • Text Marketing FAQs
  • Text Messaging Software
  • Contact Us Now
  • Video Tours
  • Text Message Marketing Blog
  • Partner With Us
  • Privacy Policy / Terms Of Use
  • Anti-Spam Policy

Msg&data rates may apply in the US. Standard message and data rates apply in Canada. To unsubscribe from any Club Texting ® list simply send 'STOP' to 25827 (212121 in Canada) or contact Support.

Club Texting neither provides lists of phone numbers nor do we access our clients' contact lists. Club Texting is a 100% opt-in service.
Please see our Terms Of Use, Privacy Policy, & Anti-Spam Policy to learn about our stance on SPAM and your data privacy.