How To Create Your Own Bulk SMS Web Interface
Creating a bulk SMS interface using the HTTP/S API to send bulk SMS text messages is easier than you think. All you’ll need is a text editor and a web server configured with PHP.
So let’s get right to the meat of this post: you want to create a simple web-based interface that you can use to send messages to your contacts. Although this can be achieved with one file, we’ve decided to split it into two separate files for the sake of clarity. They are .html and .php files respectively, and will be explained for the purposes of bulk SMS messaging as we go along.
Note: The examples below are not intended to be advanced, and are merely used for illustrative purposes.
Collecting Data
Creating an .html file is the first step to create your own bulk SMS texting interface, and depends on the <form> tag. Those experienced with html will know that the form method can either be set to post or get. While either can be used in the example below, we’ve chosen to use the post method. Here’s what the code looks like:
<form method=”post” action=”Send.php”>
Comment: Opening the form tag with the post method. In the action we define the .php the values collected in this file will be passed to.
API_ID: <input name=”api_id”> <br/>
Comment: One of the message parameters required is the API_ID, which is supplied upon registration for the HTTP/S API.
Note: With registration 10 free test credits (pre-populated) is supplied.
Username: <input name=”user”> <br/>
Comment: This field prompts you for your SMS gateway account username.
Password: <input name=”password”> <br/>
Comment: This field prompts you for your SMS gateway account password.
Mobile Number: <input> <br/>
Comment: Here you can enter all the destination numbers you want to send your bulk SMS text messages to.
Message Text: <textarea name=”text”></textarea> <br/>
Comment: This field will allow you to enter the message you want to send to your contacts.
<input value=”Send SMS”>
Comment: And finally, the submit button.
</form>
Comment: Close the form tag.
As you can see from the above, it’s not rocket science at all. Just take note that the above is a very simple form that requires you to input all values, which can also be hardcoded using the value parameter of the <form> tag.
Submitting Data
So what happens once you click on ‘Submit’? Let’s look at the file we defined as the action in the <form> tag above. Note that the name of the file abovehas to correspond with the one below. Also ensure that they are in the same directory (or ‘Folder’).
<?
# Collect parameters from HTML form submission
$message = array(
‘to’ => $_REQUEST['to'],
‘text’ => $_REQUEST['text'],
‘api_id’ => $_REQUEST['api_id'],
‘user’ => $_REQUEST['user'],
‘password’ => $_REQUEST['password']
);
Comment: Data collected in the .html file above is passed to an array in the .php file.
$api_url = ‘http://api.clickatell.com/http/sendmsg?’;
Comment: This is the HTTP/S API URL.
# Urlencode parameters
foreach ($message as $parameter => $value )
{
$api_url .= $parameter . ‘=’ . urlencode($value) . ‘&’;
}
Comment: The data collected in the array is appended to the API URL above.
$result = file_get_contents($api_url);
Comment: Values are passed to the API, and a corresponding result code is inserted into the $result variable.
echo “API Response: $result\n”;
?>
Comment: The echo command above displays the result of your API call. Should you get a Message ID, then the message was successfully sent. Alternatively you’ll get an error message, at which point you need to look at your files or the data entered and correct the error. And that’s bulk SMS text messaging in a nutshell.
From here on you can elaborate on the files above to improve bulk SMS messaging functionality.
For more information and to see what other APIs can be used for text messaging purposes, simply navigate to our bulk SMS page.
No related posts.
Related posts brought to you by Yet Another Related Posts Plugin.
This website uses IntenseDebate comments, but they are not currently loaded because either your browser doesn't support JavaScript, or they didn't load fast enough.
One Comment On This Post
[...] be able to use to collect fan names and numbers. This form will be similar than the one created in How to Create Your Own Bulk SMS Interface, but with a few changes that will allow efficient future communication through the SMS [...]