Message-ID: <1738024201.15855.1614958461279.JavaMail.confluence@wiki> Subject: Exported From Confluence MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_Part_15854_683705654.1614958461278" ------=_Part_15854_683705654.1614958461278 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Location: file:///C:/exported.html sendSMS - Java

sendSMS - Java

=20
=20
=20
=20

 

=20
=20
=20
=20
=20
=20

Send a text message to the specified recipient. Optionally, sends can be= scheduled.

See also What is a s= ent message? 

=20
=20
=20
=20
=20
=20

With the minimum arguments required, sends 'my message' to 447000000000 = with sender ID 'Sender':

Example
=20
Hashtable<String, String> result =3D tmClient.sendSMS("My =
message", "447000000000", "Sender", 72, "&quo=
t;, "", null);
System.out.println("Used " + result.get("credits_used")=
 + " Credits, ID: " + result.get("message_id") + "=
, Status: " + result.get("status"));
=20
=20
=20
=20
=20
=20
=20

As above, but sets validity to 72 hours and is scheduled for sending on = 1st Jan 2013 at 01:00 GMT:

Example
=20
Calendar cal_end =3D Calendar.getInstance();
cal_end.set(2013, 1, 1, 1, 0, 0);
Hashtable<String, String> result =3D tmClient.sendSMS("My messag=
e", "447000000000", "Sender", 72, "", &q=
uot;myTag", cal.getTime());
System.out.println("Used " + result.get("credits_used")=
 + " Credits, Scheduled ID: " + result.get("scheduled_id&quo=
t;) + ", Status: " + result.get("status"));
=20
=20
=20
=20
=20
=20
=20

Arguments:

=20
=20
=20
=20

 

=20
=20
=20
=20
=20
=20

String message: 

=20
=20
=20
=20

the textual content of the message to be sent. Up to 612 characters from= the GSM alphabet. See Supported Characters for t= he characters we support. Please ensure messages are encoded in UTF-8.

=20
=20
=20
=20
=20
=20

String mobile_number: 

=20
=20
=20
=20

the mobile number of the intended recipient, in international format, e.= g. 447000000000. Only one number is allowed. To send a message to multiple = recipients, you must call the function for each number.

=20
=20
=20
=20
=20
=20

String originator: 

=20
=20
=20
=20

sender ID: text (up to 11 alpha-numeric characters) or the international= mobile number (up to 16 digits) of the sender, to be displayed to the reci= pient, e.g. 447777123123 for a UK number.

=20
=20
=20
=20
=20
=20

int validity:

=20
=20
=20
=20

an integer from 1 to 72 (the default), indicating the number of hours du= ring which the message is valid for delivery. Messages which cannot be deli= vered within the specified time will fail.

=20
=20
=20
=20
=20
=20

String email:

=20
=20
=20
=20

(optional) available to txtUs Plus customers only. Spec= ifies the email address for incoming responses. If you specify an email add= ress, you must specify an originator that is a txtUs Plus number that is on= your account, or you will get an error response.

=20
=20
=20
=20
=20
=20

String custom:

=20
=20
=20
=20

(optional) an alpha-numeric string, 1-20 characters long, which will be = used to 'tag' your outgoing message and will appear in delivery reports, th= us facilitating filtering of reports (see getDeliveryReport function)

=20
=20
=20
=20
=20
=20

Date schedule:

=20
=20
=20
=20

(optional) date to schedule the message to be sent at a given time (Euro= pe/London time)

=20
=20
=20
=20
=20
=20

Returns:


an Hashtable with 4 keys: 'message_id', 'scheduled_id', 'credits_u= sed', 'status' e.g.
result.get("message_id")

=20
=20
=20
=20
Hashtable key

Value

message_id 

Integer. The unique ID of the message sent. Y= ou can use this ID to find the status of the sent message in a delivery rep= ort. However for scheduled messages (i.e. where you have specified a 'sched= ule' argument), the ID will be zero.

scheduled_id 

String. The unique ID of the scheduled messag= e. You can use this ID later to delete a previously scheduled message. Unle= ss the message has been scheduled for a future date, the ID will be zero.

credits_used 

Integer. The number of credits used to send t= he message (up to 3 for UK or 6 for international). If the message is sched= uled for future sending, this value indicates how many credits will be used= when it is sent.

status 

String. Values possible are SENT, QUEUED, or = SCHEDULED. Indicates whether the message was put in a queue for processing = as soon as resources allow (QUEUED), sent immediately (SENT), or scheduled = for future sending at your request (SCHEDULED).

=20
=20
=20
=20
=20
=20

Specific error codes:

=20
=20
=20
=20
Code

Meaning

0 Refused (bad number or trying international send= ing without a valid account).
1 Bad username or password.
2 You have zero credits.
3 The originator is invalid or too long.
4

The originator is invalid or missing.

5 The message is invalid or too long.
6 You have insufficient credits to send this messa= ge.
7

The message is invalid or missing.

8

The message contains unsupported characters (= these will be listed in the error message).

9

The mobile number is invalid or too short.

10 The mobile number is invalid or not an integer.<= /td>
30 Invalid email address format.
31

An email address was specified, but the origi= nator specified was not a txtUs number on your account.

32

If specified, the validity period (in hours) = must be between 1 and 72 inclusive.

33

If specified, the custom field must be alpha-= numeric and up to 20 characters in length.

34 The 'schedule' parameter is not in ISO 8601 date= format.
=20
=20
=20
=20
=20
=20
=20 =20
=20
=20
=20
=20

 

=20
=20
=20
=20

 

=20
=20
=20
------=_Part_15854_683705654.1614958461278--