Send SMS Text API
We offer a RESTful and lightweight interface for sending SMS Text messages. This option is perfect for mail-merging text appointment reminders, alerts, marketing campaigns, delivery confirmations and payroll information. |
|
<?php
// Innovative Text API URL
$postUrl = "http://rest.innovativetxt.com/smsapi/index.php";
//Formatted data $fields = “to=xxxx&from=xxxx&
text=xxxx&api_key=KEY&api_secret=API SECRET”
// In this example, POST request was made using PHP's CURL
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $postUrl);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
//Response of the POST request
$response = curl_exec($ch);
curl_close($ch);
//Write out the response
echo $response;
?>
try
{
// InnovativeTXT POST URL
string url = "http://rest.innovativetxt.com/smsapi/index.php";
// XML-formatted data
string toSender = "447879854566";
string fromSender = "CompanyName";
string textMessage = "Thanks for Choosing Innovative Text.";
string fields = "?to=" + toSender + "&from=" + fromSender
+ "&text=" + textMessage + "&api_key=KEY&api_secret=API SECRET";
url = url + fields;
// web request start
Uri uri = new Uri(url);
string data = "field-keywords=ASP.NET 2.0";
if (uri.Scheme == Uri.UriSchemeHttp)
{
// create a request on behalf of uri
HttpWebRequest request =
(HttpWebRequest)HttpWebRequest.Create(uri);
// setting parameter for the request
request.Method = WebRequestMethods.Http.Post;
request.ContentLength = data.Length;
request.ContentType = "application/x-www-form-urlencoded";
// a stream writer for the request
StreamWriter writer = new
StreamWriter(request.GetRequestStream());
// write down the date
writer.Write(data);
//close the stream writer
writer.Close();
// getting response from the request
HttpWebResponse response =
(HttpWebResponse)request.GetResponse();
// Get the stream associated with the response.
Stream receiveStream = response.GetResponseStream();
// Pipes the stream to a higher level stream reader
with the required encoding format.
StreamReader readStream = new
StreamReader(receiveStream, System.Text.Encoding.UTF8);
// to write a http response from the characters
Response.Write(readStream.ReadToEnd());
// close the response
response.Close();
// close the reader
readStream.Close();
}
}
catch (Exception exp)
{
// catch for unhelded exception
Response.Write(exp.Message);
}
package sendsms_innovative;
import java.net.*;
import java.io.*;
public class URLConnDemo {
public static void main(String[] args) {
String request = "http://rest.innovativetxt.com/smsapi/index.php?to=923226101777& from=CompanyName&text='Your Message'&api_key=XXXXXXX&api_secret=XXXXXXXX";
try
{
URL url = new URL(request);
URLConnection urlConnection = url.openConnection();
HttpURLConnection connection = null;
if(urlConnection instanceof HttpURLConnection)
{
connection = (HttpURLConnection) urlConnection;
}
else
{
System.out.println("Please enter an HTTP URL.");
return;
}
BufferedReader in = new BufferedReader(
new InputStreamReader(connection.getInputStream()));
String urlString = "";
String current;
while((current = in.readLine()) != null)
{
urlString += current;
}
System.out.println(urlString);
}catch(IOException e)
{
e.printStackTrace();
}
}
}
|
Parameter |
Description |
from |
Required – Sender
Name (Alpha Numeric or Dedicated Long Code) |
to |
Required – Mobile
number in International Format & and
one recipient per request. e.g. 447873981355
for UK |
message |
Required – Message
to be sent |
api_key |
Required – Your
Innovative Text Assigned API Key |
api_secret |
Required – Your
Innovative Text API Secret |
type |
Optional. Not required for normal text messages. This needs to be set to unicode, if sending the unicode message. ( e.g for Message in Arabic). |
flashsms |
Optional. Set to 0 for Flash SMS. |
|
We Support Unicode messaging for multiple languages support. Length of a SMS is 160 characters in ASCII (latin symbols) or 70 characters in UNICODE. If quantity of symbols exceeds 160 symbols in ASCII or 70 characters in UNICODE, size and calculation of one SMS will be 153 characters in ASCII and 63 characters in UNICODE
JSON Sucessful response, sent in one part: |
{"message-count":1,"messages":[{"status":0,"to":"443335217631","client-ref":"3837373","message-id":"1905553210","message-price":0.01,"remaining-balance":33.1305}]} |
In case of any failuer the JSON response is below.
JSON Error response, sent in one part:
|
{"messagecount":1,"status":4,"clientref":"3837373","error-text":"Invalid Mobile Number."} |
The status code and there description is detailed below
Status Code |
Description |
0 |
The message was successfully accepted for delivery by Innovative Text. |
1 |
Throttled, you are sending messages too fast, get back and try again. |
2 |
Insufficient Credit. |
3 |
The api_key / api_secret is either invalid or disabled. |
4 |
Invalid Parameters. Please ensusure phone number to be international format. |
5 |
Innovative text server error (component mobile authentication), please report and try again. |
Incoming SMS API
Once you've configured your Innovative Text Virtual Long Code / Short Code, set the forward URL in the API Setting page to forward all incoming messages to your server.
The Incoming message will forward to your system via HTTP request. Example URL is following.
http://www.mydomain.com/myscript.php?
msisdn=445257878787&text=keyword+and+some+other+text&to=1214525254
Parameter |
Description |
msisdn |
Optional. Sender ID |
to |
Recipient number (your Long virtual mobile number). |
text |
Content of the message |
messageid |
Message ID |
message-timestamp |
When we started to push the message to your callback URL in the following format YYYY-MM-DD HH:MM:SS e.g. 2013-06-05 10:32:18 |
Delivery Reports
Please set up the delivery receipts URL in to your account at the API Settings page, we will post the information as query string to the provided URL.
http://www.xxx.com?to=447871234457&msisdn=447873981355&status=accepted&err-code=1&network-code=23410&message-timestamp=2013-01-05 08:13:04
Parameter |
Description |
msisdn |
Number message was delivered to. |
to |
Sender Id of the message.
|
status |
Status of the message (possible message
can be) delivered, expired, failed, accepted, buffered,
unknown) |
network-code |
Optional identifier of a mobile network
MCCMNC. Wikipedia list here. |
message-timestamp |
When the delivery report URL was pushed
to you.
YYYY-MM-DD HH:MM:SS e.g. 2012-04-05 09:22:57 |
scts |
UTC time when got notification mobile network in the following format YYMMDDHHMM e.g. 1303171426 is 2011 Jan 18th 14:26 |
price |
Message price |
clientref |
The custom variable provided by you with request submission. |