oursms.app client library
Get the project from jitpack
or directly from here
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.github.MouamleH</groupId>
<artifactId>oursms-java</artifactId>
<version>0.0.3</version>
</dependency>
</dependencies>
First you create a client with your api credentials
OursmsClient client = new OursmsClient(<USER-ID>, <API-KEY>);
Then you can send messages as follows
try {
final Optional<SentMessageData> oSentMessageData = client.sendOneMessage(<MOBILE-NUMBER, <MESSAGE-TEXT>);
if (oSentMessageData.isPresent()) {
final SentMessageData sentMessageData = oSentMessageData.get();
// store message id to check status later if you want
}
} catch (IOException e) {
// handle exception
}
Here you send the otp as an integer and the api takes care of appending it to a message body
try {
final Optional<SentMessageData> oSentMessageData = client.sendOTP(<MOBILE-NUMBER, <OTP>);
if (oSentMessageData.isPresent()) {
final SentMessageData sentMessageData = oSentMessageData.get();
// store message id to check status later if you want
}
} catch (IOException e) {
// handle exception
}
try {
final List<MessageStatus> messageStatus = client.getMessageStatus(<MESSAGE-ID>);
// This list typically contains only one element
} catch (IOException e) {
// handle exception
}