Developers

SMS API Interface

Example scripts in PHP – Examples of sending SMS messages in PHP

Download full Gretor SMS specification v2.1

Attention! Password have to be encrypted using MD5!

Example no 1 – SMS sends directly using PHP.

<?php

$username = “username”;

$password = md5(“password”);

$to = “30123456789”;

$from = “name”; // sender name have to be activated

$message= urlencode(“My message”);

if ($username && $password && $to && $message)

?>

Example no 2 – SMS sends from HTML form using PHP.

<?php

if (strlen($_POST[‘sms_from’])>0 &&

strlen($_POST[‘sms_message’])>0)

?>

<html>

<body>

<form name=”sms” method=”POST” action=””>

<table>

<tr>

<td>From:</td>

<td><input type=”text” name=”sms_from” value=””></td>

</tr>

<tr>

<td>To:</td>

<td><input type=”text” name=”sms_to” value=””></td>

</tr>

<tr>

<td>Message:</td>

<td><textarea name=”sms_message”></textarea></td>

</tr>

<tr>

<td colspan=”2″><input type=”submit” value=”send”></td>

</tr>

</table>

</form>

</body>

</html>

Example no 3 – Mass SMS sends using cURL library.

<?php

$username = ‘user’;

$password = md5(‘pass’);

$from = ‘Yourname’;

$to = array(‘number1′,’number2’);

$message = urlencode(‘Test message’);

echo send_sms($username,$password,$from,$to,$message);
function send_sms($username,$password,$from,$to,$message)

?>

API Error codes and message delivery statuses

Message delivery statuses

NumberStatusDescription
401NOT_FOUNDWrong ID or report has expired.
402EXPIREDMessages expired.
403SENTMessage is sent.
404DELIVEREDMessage is delivered to recipient.
405UNDELIVEREDMessage is undelivered (invalid number, roaming error etc).
406FAILEDSending message failed – please report it to us.
408UNKNOWNNo report (message may be either delivered or not).
409QUEUEDMessage is waiting to be sent.
410ACCEPTEDMessage is delivered to operator.

API Error Codes

Error codeDescription
8Error in request (Please report)
11Message too long or there is no message or parameter nounicode is
set and special characters (including Polish characters) are used.
12Message has over 160 chars when parameter &smp;single=1.
13Lack of valid phone numbers (invalid or blacklisted numbers).
14Invalid sender name.
17FLASH message cannot contain special characters.
18Invalid number of parameters.
19Too many messages in one request.
20Invalid number of IDX parameters.
27Too long IDX parameter. Maximum 255 chars.
30Wrong UDH parameter when &datacoding=bin
40No group with given name in phonebook.
41Chosen group is empty.
50Messages may be scheduled up to 3 months in the future.
52Too many attempts of sending messages to one number (maximum 10
attempts whin 60s).
53Not unique idx parameter, message with the same idx has been already
sent and &check_idx=1.
54Wrong date format (only unix timestamp and ISO 8601) when
&date_validate=1.
56The difference between date sent and expiration date can’t be less
than 1 and more tha 12 hours.
57Recipient\’s number is on blacklist.
70Invalid CALLBACK address in notify_url parameter.
72Parameter notify_url may be used only for single request (cannot be
used for bulk submissions).
74Date of sent is outside allowed timeframe set for this user.
101Invalid authorization info. ATTENTION! API password
ma be different than web panel password.
102Invalid username or password.
103Insufficient credits on Your account.
104No such template.
105Wrong IP address (for IP filter turned on).
200Unsuccessful message submission, please repeat zour request.
201System internal error (please report).
202Too many simultaneous request, message won’t be sent.
300Invalid parameter &points value, &points=1 expected.
301ID of messages doesn’t exist.
400Invalid message ID of a status response.
999System internal error (please report).
4000General Phonebook error.
4001Action not available for this account.
4002Invalid action.
4003Invalid parameter usage.
4004Too large limit parameter value (i.e. for list_contacts action
maximum value is 200).
4100General groups’ action error.
4101Group not found.
4110General group’s name error.
4111Invalid group’s name.
4112Group’s name musn’t be empty.
4113Group’s name too short (min 2 chars).
4114Group’s name too long (max 32 chars).
4115Forbidden chars appeard in group’s name.
4116Group already exists.
4121Invalid Info field value for groups.
4122Too long Info field value for contact (max 200 chars).
4200General contact error.
4201Contact not found.
4210General phone number error.
4211Invalid phone number.
4212Contact has to contain phone number.
4213Phone number is too short.
4214Phone number is too long.
4220First name error.
4221First name too short (min 2 chars).
4222First name too long (max 100 chars).
4230Last name error.
4231Last name too long (min2 chars).
4232Last name too long (max 100 chars).
4240Contact Info ffield error.
4241Too long Info field value for contact (max 200 chars).
4250E-mail address error for this contact.
4260Birth date error for this contact.
4270Group error for this contact.
4271Group not found.
4272Group name is neccessary for group actions.
4280Gender error.

SMPP Interface – SMPP Protocol

SMPP (Short Message Peer-to-Peer), is open standarized protocol designed to provide direct data communication between telecommunication system like Message Centres (SMSC) and Short Message Entities (SME/ESME) in order to send SMS messages between them. SMPP protocol is mostly used for communication with GSM operators and SMS aggregators (ESME SMSC).

SMPP protocol is based on binary encoded pairs request/response PDUs (protocol data units, or packets) exchanged over OSI layer 4 connections (transport layer). Message exchange may be synchronous, where each peer waits for a response for each PDU being sent, or asynchronous, where multiple requests can be issued without waiting and acknowledged in a skew order by the other peer; the number of unacknowledged requests is called a window; for the best performance both communicating sides must be configured with the same window size.

Communication system used in SMPP allows to send SMS message without using handsets, GSM modems or SIM cards. SMPP systems allows to use a number of features not available for standard GSM devices i.e. alphanumeric sender names instead of standard phone numbers.

For more details about SMPP accounts please contact us.

Email to SMS Interface

Description of E-Mail to SMS Interface

Using mail2SMS tool you will be able to send SMS in very easy way. You just need to send a properly created e-mail to sms.do@sms.gretor.com. As topic of e-mail username and password encrypted in md5 should be given. Content of e-mail should contain proper parameters.

Basic parameters:

ParameterDescritionExample valuesAdditional informartions
fromSender namefrom=Gretor SMSSender name must be active.
toRecipients’s numberto=306931234***
raportRequest to ger response e-mailraport=1Response is sent back as e-mail message.
messageMessage contentmessage=TESTIt has appear as the last parameter!

Important information!

  • Messages may be sent in following encoding: plain / quotedprintable / base64.
  • Phone number MUST NOT contain plus char “+” at the beginning.
  • Parameter message MUST at the and of the e-mail message (as the last parameter).
  • Sender name (parameter from) MUST be active.

Examples

Example of sending SMS message.

ADRES: sms.do[at]sms.gretor.com.com
TEMAT: login@8456fkty567gb3bg37b357b3457b3457
TREŚĆ: from=Gretor SMS&to=30693123***&raport=1&message=MESSAGE CONTENT

Example of response to properly send SMS request.

ADRES: sms.do[at]sms.gretor.com
TEMAT: Response SMSAPI
TREŚĆ: Gretor SMS:30693123***:OK:message_id:cost

Example of response when error occured.

ADRES: sms.do[at]sms.gretor.com
TEMAT: Response Gretor SMS
TREŚĆ: Gretor SMS:306931234***:ERROR:error_code

7bit GSM alphabet – This is the 7 bit default alphabet as specified by GSM 03.38.

All chars outside this charset are considered to be special chars and causes shortening single message from 160 chars to 70 chars. Using only chars from this list won’t shorten the message.

Notice that characters ^ { } [ ] \ ~ | [enter] € are counted double when sending message without special chars because of GSM specification requirements.

CharacterCharacter nameHEXDEC
@COMMERCIAL AT0x000
£POUND SIGN0x011
$DOLLAR SIGN0x022
¥YEN SIGN0x033
èLATIN SMALL LETTER E WITH GRAVE0x044
éLATIN SMALL LETTER E WITH ACUTE0x055
ùLATIN SMALL LETTER U WITH GRAVE0x066
ìLATIN SMALL LETTER I WITH GRAVE0x077
òLATIN SMALL LETTER O WITH GRAVE0x088
ÇLATIN CAPITAL LETTER C WITH CEDILLA0x099
LINE FEED0x0A10
ØLATIN CAPITAL LETTER O WITH STROKE0x0B11
øLATIN SMALL LETTER O WITH STROKE0x0C12
CARRIAGE RETURN0x0D13
ÅLATIN CAPITAL LETTER A WITH RING ABOVE0x0E14
åLATIN SMALL LETTER A WITH RING ABOVE0x0F15
ΔGREEK CAPITAL LETTER DELTA0x1016
_LOW LINE0x1117
ΦGREEK CAPITAL LETTER PHI0x1218
ΓGREEK CAPITAL LETTER GAMMA0x1319
ΛGREEK CAPITAL LETTER LAMBDA0x1420
ΩGREEK CAPITAL LETTER OMEGA0x1521
ΠGREEK CAPITAL LETTER PI0x1622
ΨGREEK CAPITAL LETTER PSI0x1723
ΣGREEK CAPITAL LETTER SIGMA0x1824
ΘGREEK CAPITAL LETTER THETA0x1925
ΞGREEK CAPITAL LETTER XI0x1A26
ESCAPE TO EXTENSION TABLE0x1B27
FORM FEED0x1B0A27 10
^CIRCUMFLEX ACCENT0x1B1427 20
{LEFT CURLY BRACKET0x1B2827 40
}RIGHT CURLY BRACKET0x1B2927 41
\REVERSE SOLIDUS (BACKSLASH)0x1B2F27 47
[LEFT SQUARE BRACKET0x1B3C27 60
~TILDE0x1B3D27 61
]RIGHT SQUARE BRACKET0x1B3E27 62
|VERTICAL BAR0x1B4027 64
EURO SIGN0x1B6527 101
ÆLATIN CAPITAL LETTER AE0x1C28
æLATIN SMALL LETTER AE0x1D29
ßLATIN SMALL LETTER SHARP S (German)0x1E30
ÉLATIN CAPITAL LETTER E WITH ACUTE0x1F31
SPACE0x2032
!EXCLAMATION MARK0x2133
\”QUOTATION MARK0x2234
#NUMBER SIGN0x2335
¤CURRENCY SIGN0x2436
%PERCENT SIGN0x2537
&AMPERSAND0x2638
APOSTROPHE0x2739
(LEFT PARENTHESIS0x2840
)RIGHT PARENTHESIS0x2941
*ASTERISK0x2A42
+PLUS SIGN0x2B43
,COMMA0x2C44
HYPHEN-MINUS0x2D45
.FULL STOP0x2E46
/SOLIDUS (SLASH)0x2F47
0DIGIT ZERO0x3048
1DIGIT ONE0x3149
2DIGIT TWO0x3250
3DIGIT THREE0x3351
4DIGIT FOUR0x3452
5DIGIT FIVE0x3553
6DIGIT SIX0x3654
7DIGIT SEVEN0x3755
8DIGIT EIGHT0x3856
9DIGIT NINE0x3957
:COLON0x3A58
;SEMICOLON0x3B59
<LESS-THAN SIGN0x3C60
=EQUALS SIGN0x3D61
>GREATER-THAN SIGN0x3E62
?QUESTION MARK0x3F63
¡INVERTED EXCLAMATION MARK0x4064
ALATIN CAPITAL LETTER A0x4165
BLATIN CAPITAL LETTER B0x4266
CLATIN CAPITAL LETTER C0x4367
DLATIN CAPITAL LETTER D0x4468
ELATIN CAPITAL LETTER E0x4569
FLATIN CAPITAL LETTER F0x4670
GLATIN CAPITAL LETTER G0x4771
HLATIN CAPITAL LETTER H0x4872
ILATIN CAPITAL LETTER I0x4973
JLATIN CAPITAL LETTER J0x4A74
KLATIN CAPITAL LETTER K0x4B75
LLATIN CAPITAL LETTER L0x4C76
MLATIN CAPITAL LETTER M0x4D77
NLATIN CAPITAL LETTER N0x4E78
OLATIN CAPITAL LETTER O0x4F79
PLATIN CAPITAL LETTER P0x5080
QLATIN CAPITAL LETTER Q0x5181
RLATIN CAPITAL LETTER R0x5282
SLATIN CAPITAL LETTER S0x5383
TLATIN CAPITAL LETTER T0x5484
ULATIN CAPITAL LETTER U0x5585
VLATIN CAPITAL LETTER V0x5686
WLATIN CAPITAL LETTER W0x5787
XLATIN CAPITAL LETTER X0x5888
YLATIN CAPITAL LETTER Y0x5989
ZLATIN CAPITAL LETTER Z0x5A90
ÄLATIN CAPITAL LETTER A WITH DIAERESIS0x5B91
ÖLATIN CAPITAL LETTER O WITH DIAERESIS0x5C92
ÑLATIN CAPITAL LETTER N WITH TILDE0x5D93
ÜLATIN CAPITAL LETTER U WITH DIAERESIS0x5E94
§SECTION SIGN0x5F95
¿INVERTED QUESTION MARK0x6096
aLATIN SMALL LETTER A0x6197
bLATIN SMALL LETTER B0x6298
cLATIN SMALL LETTER C0x6399
dLATIN SMALL LETTER D0x64100
eLATIN SMALL LETTER E0x65101
fLATIN SMALL LETTER F0x66102
gLATIN SMALL LETTER G0x67103
hLATIN SMALL LETTER H0x68104
iLATIN SMALL LETTER I0x69105
jLATIN SMALL LETTER J0x6A106
kLATIN SMALL LETTER K0x6B107
lLATIN SMALL LETTER L0x6C108
mLATIN SMALL LETTER M0x6D109
nLATIN SMALL LETTER N0x6E110
oLATIN SMALL LETTER O0x6F111
pLATIN SMALL LETTER P0x70112
qLATIN SMALL LETTER Q0x71113
rLATIN SMALL LETTER R0x72114
sLATIN SMALL LETTER S0x73115
tLATIN SMALL LETTER T0x74116
uLATIN SMALL LETTER U0x75117
vLATIN SMALL LETTER V0x76118
wLATIN SMALL LETTER W0x77119
xLATIN SMALL LETTER X0x78120
yLATIN SMALL LETTER Y0x79121
zLATIN SMALL LETTER Z0x7A122
äLATIN SMALL LETTER A WITH DIAERESIS0x7B123
öLATIN SMALL LETTER O WITH DIAERESIS0x7C124
ñLATIN SMALL LETTER N WITH TILDE0x7D125
üLATIN SMALL LETTER U WITH DIAERESIS0x7E126
àLATIN SMALL LETTER A WITH GRAVE0x7F127

SMS signup arrow