SEO Metadata | ||
---|---|---|
| ||
|
To send an SMS with our Java wrapper, download and unzip the wrapper from here, then copy the TMRestClient.jar file into your CLASSPATH or added as a command-line option in your java virtual machine e.g:
Panel |
---|
java -classpath /usr/java/library/TMRestClient.jar |
Now put the following code somewhere in a Java file and execute it to send an SMS – don't forget to substitute your own API username and password and a real mobile number to send to!
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
import java.util.Map; import uk.co.textmarketer.RestAPI.*; import uk.co.textmarketer.RestAPI.RestClientException; public class SendSMS { public static void main(String[] args) { RestClient tmClient; tmClient = new RestClient("myAPIusername", "myAPIpassword", RestClient.ENV_PRODUCTION); try { Hashtable<String, String> result; result = tmClient.sendSMS("My message", "447000000000", "Sender", 72, "", "", null); System.out.println("Message sent with ID " + result.get("message_id")); } catch(RestClientException e) { Hashtable<String, String> errors = tmClient.getLastErrors(); for(Map.Entry<String, String> error: errors.entrySet()) System.out.println("Error code " + error.getKey() + ": " + error.getValue()); } } } |
Tip |
---|
You can find your API username and password (which may be different to your web interface username/password) via your account: https://messagebox.textmarketer.co.uk/#!accountsettings/
|
Warning | ||
---|---|---|
| ||
Our example code is an illustration of how you might integrate with our systems and is not certified for production environments. You are responsible for testing and QA. |
Panel | ||
---|---|---|
| ||
|