Sunteți pe pagina 1din 9

HTTP API

USERGUIDE DOCUMENTATION
SmartSMSSolutions SMS A.P.I. provides simple yet powerful gateway to connect any application
with our SMS gateway via HTTP POST/GET. This documentation helps to provide the connection
procedure common programing languages.
TABLE OF CONTENTS

INTRODUCTION .............................................................................................................................................................................. 2

Details of the API......................................................................................................................................................................... 2

http API PARAMETERS – For sending SMS .............................................................................................................................. 3

The api responses and their meanings ..................................................................................................................................... 4

Message Sent Successfully ....................................................................................................................................................... 4

Other Responses ......................................................................................................................................................................... 4

Response Format ........................................................................................................................................................................ 4

http API PARAMETERS – For CHECKING BALANCE .............................................................................................................. 5

SMS Units Balance Response ................................................................................................................................................... 5

SAMPLE CODE – PHP (GET) ......................................................................................................................................................... 6

SAMPLE CODE – PHP (POST) .......................................................................................................................................................7

1
INTRODUCTION

Our SMS services is powered by a powerful Application Programming Interface (API) that connection to
application seamless. The API is robust and can handle hundreds of thousands of connections per minute. It is
a fully restful API based on HTTP POST methodology.

The API can be implanted in any of the following programming language

 PHP
 Java
 Python
 C#
 JSON

Whatever the application language, all that is needed is to POST the data to the API URL.

Details of the API

A very robust support for the API can be found at http://smartsmssolutions.com/apis

2
HTTP API PARAMETERS – FOR SENDING SMS

The SMS API can utilized via HTTP POST or HTTP GET. The parameters for the two connection types are
described below.

Parameter Title Parameter Value Comment


URL https://api.smartsmssolutions.com/smsapi.php The URL for the API. Data is either
POSTed to this URL or GET from it.
Username username Your username on
SmartSMSSolutions.com. Preferably
without spaces, since different engines
renders space differently. (‘+’ vs ‘%20’
Password password Your password on
SmartSMSSolutions.com.
Sender ID sender This is what the recipients of the
messages will see as the sender of the
message. This must the 11 characters
or less. Longer sender ids are
automatically shortened to meeting
the standard. This should be URL
encoded when using the GET
protocol.
Recipients or recipient These are the phone numbers the
the Phone messages are to be sent. Multiple
Numbers phone numbers are to be separated
by a comma ‘,’. Large quantities of
phone numbers can be called via the
POST method. Recipients via the GET
method are advised to be limited to
100 phone numbers at once. This is to
avoid the possibilities of running into
the HTTP Error 400 (Bad Request -
Request Too Long)
Message message The message you will like to send to
the recipients. This should be URL
encoded when using the GET
protocol.
3
THE API RESPONSES AND THEIR MEANINGS

Message Sent Successfully

When messages are sent successfully the API replies in the format shown below:

OK<space>Number of Units Used<space>Failed Phone Numbers

Example: OK 26 08111111111,08222222222

Other Responses

Response Code Meaning


2904 SMS Sending Failed
2905 Invalid username/password combination
2906 Credit exhausted
2907 Gateway unavailable
2908 Invalid schedule date format
2909 Unable to schedule
2910 Username is empty
2911 Password is empty
2912 Recipient is empty
2913 Message is empty
2914 Sender is empty
2915 One or more required fields are empty
2916 Sender ID not allowed by the operator.

In all of the above instances, the clients are never billed. If you consistently get any of the above codes you
can contact us for support.

Response Format

The API response in plain text ie text/plain.


4
HTTP API PARAMETERS – FOR CHECKING BALANCE

The SMS API can utilized via HTTP POST or HTTP GET. The parameters for the two connection types are
described below.

Parameter Title Parameter Value Comment


URL https://api.smartsmssolutions.com/smsapi.php The URL for the API. Data is either
POSTed to this URL or GET from it.
Username username Your username on
SmartSMSSolutions.com. Preferably
without spaces, since different engines
renders space differently. (‘+’ vs ‘%20’
Password password Your password on
SmartSMSSolutions.com.
Call for SMS balance This must best to true to get the SMS
units balance balance

SMS Units Balance Response

The API replies with a numeric value of the SMS units balance.

5
SAMPLE CODE – PHP (GET)

function sendsms_get($username, $password, $message, $senderid, $recipients) {


$message = urlencode($message);
$senderid = urlencode($senderid);

$url =
'http://api.smartsmssolutions.com/smsapi.php?username='.$username.'&password='.$password.'&sender='.$
senderid.'&recipient='.$senderid.'&message='.$message.'&';
$send = file_get_contents($url);
return $send;
}

$username = '';
$password = '';
$message = '';
$senderid = '';
$recipients = '';
$url = 'http://api.smartsmssolutions.com/smsapi.php';
$get_sms = sendsms_get($username, $password, $message, $senderid, $recipients);

echo $get_sms;

6
SAMPLE CODE – PHP (POST)

function sendsms_post ($url, array $params) {


$params = http_build_query($params);
$ch = curl_init();

curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $params);

$output=curl_exec($ch);

curl_close($ch);
return $output;
}

$sms_array = array (
'username' => $username,
'password' => $password,
'message' => $message,
'sender' => $senderid,
'recipient' => $recipients

);

$post_sms = sendsms_post($url, $sms_array);


echo $post_sms;

7
I STILL CANNOT GET IT TO WORK

Please feel free to contact support and we’ll be glad to provide the needed support.

Phone Numbers

 08035515868
 07034243326

S-ar putea să vă placă și