Send an SMS Using Java
The Textmagic API Java wrapper can save you a lot of time, as it includes all the necessary API commands and tests. It only takes a few seconds to download it from GitHub and to install it into your own app or software. After installation, you’ll then be able to send text messages.
Get it now on GitHubInstallation Instructions
Quick Installation
The easiest way to install the Textmagic Java wrapper is from Maven. You can add the following dependency to your existing project, specifying the latest version in the version tag:
com.textmagic.sdk textmagic-java-sdk 1.2.0
Manual Installation
You can also install the Textmagic Java wrapper from the GitHub repository using git. Run the following commands:
git clone git://github.com/textmagic/textmagic-rest-java.git cd textmagic-rest-java mvn install
Requirements
The Java wrapper has the following requirements:
- Java SE6 or higher
- Apache Maven 2.0 or higher
Send an SMS using Java (an example)
Below is an example on how to send a text message using Java.
package com.textmagic.sdk; import com.textmagic.sdk.RestClient; import com.textmagic.sdk.RestException; import com.textmagic.sdk.resource.instance.*; import java.util.Arrays; public class Example{ public static void main(String[] args) throws RestException { RestClient client = new RestClient("", " "); TMNewMessage m = client.getResource(TMNewMessage.class); m.setText("Hello from Textmagic Java"); m.setPhones(Arrays.asList(new String[] {"99900000"})); try { m.send(); } catch (final RestException e) { System.out.println(e.getErrors()); throw new RuntimeException(e); } System.out.println(m.getId()); } }
Support
If you need help with the wrapper, or if you have any suggestions for improvements and/or if you have enquiries regarding the Java SMS gateway, please contact us by emailing [email protected].