This is the Java client library for use Mocean's API. To use this, you'll need a Mocean account. Sign up for free at moceanapi.com.
To use the client library you'll need to have created a Mocean account.
Add the following to the correct place in your project's POM file:
<dependency>
<groupId>com.github.moceanapi</groupId>
<artifactId>moceanapisdk</artifactId>
<version>1.x.x</version>
</dependency>
Add the following to build.gradle
repositories {
mavenCentral()
}
For Gradle 3.4 or Higher:
dependencies {
implementation 'com.github.moceanapi:moceanapisdk:1.x.x'
}
For older versions:
dependencies {
compile 'com.github.moceanapi:moceanapisdk:1.x.x'
}
Create a client with your API key and secret:
import com.mocean.system.Mocean;
import com.mocean.system.auth.Basic;
Basic credential = new Basic("API_KEY_HERE","API_SECRET_HERE");
Mocean mocean = new Mocean(credential);
To use Mocean's SMS API to send an SMS message, call the mocean.sms.send()
method.
The API can be called directly, using a simple array of parameters, the keys match the parameters of the API.
SmsResponse res = mocean.sms()
.setFrom("MOCEAN")
.setTo("60123456789")
.setText("Hello World")
.send();
System.out.println(res);
For your convenient, the API response has been parse to specified object.
System.out.println(res); //show full response string
System.out.println(res.status); //show response status, "0" in this case
Kindly visit MoceanApi Docs for more usage
This library is released under the MIT License