The Whispir Java library provides convenient access to the Whispir API from applications written in Java.
You can find the complete documentation of the Whispir API at developers.whispir.com.
- Java 1.8 or later
Add this dependency to your project's build file:
implementation "com.whispir:whispir-java:1.1.2"
Add this dependency to your project's POM:
<dependency>
<groupId>com.whispir</groupId>
<artifactId>whispir-java</artifactId>
<version>1.1.2</version>
</dependency>
You'll need to manually install the following JARs:
- The Whispir JAR
- Google Gson from https://repo1.maven.org/maven2/com/google/code/gson/gson/2.9.0/gson-2.9.0.jar.
The package needs to be configured with your account's username/password combination and API Key, which can be obtained by following the Obtain an API Key instructions.
WhispirExample.java
import java.util.HashMap;
import java.util.Map;
import com.whispir.Whispir;
import com.whispir.exception.WhispirException;
import com.whispir.model.Message;
import com.whispir.api.RequestOptions;
import com.whispir.param.MessageCreateParams;
public class WhispirExample {
public static void main(String[] args) {
Whispir.username = "username...";
Whispir.password = "password...";
Whispir.apiKey = "apiKey...";
MessageCreateParams params =
MessageCreateParams
.builder()
.setTo("61400400400")
.setSubject("My first message")
.setBody("Hello from Whispir Java SDK!")
.build();
try {
Message message = Message.create(params);
System.out.println(message);
} catch (WhispirException e) {
e.printStackTrace();
}
}
}
Visit the examples folder for a curated list of examples to help you get started quickly with Whispir.