JAVA SDK

Get started with the JAVA SDK

With the Java SDK you can simply import the .jar file and the requirements and then simply use the classes and methods available for an easier start with our service.

Also, if you found a bug, we fix it for you or if we add more features, you can simply update our SDK and have the lastes changes instead of losing your time updating your own code, we do it for you.

Before you start

The Java SDK have some requirements before you can start using it.

Requirements

JDK: 1.8+

JRE: 1.8+

org.json: SDK

apache.commons.codec: SDK

NetBeans IDE: Recommended but not necessary (8.2+)

Installation

Install this SDK is pretty easy, just add the SDK (with the requirements) to your SDKs and then, import the package with import com.quiubas.api.*;. Remember, you can replace the * with any of the avalaible classes in case you require only a specific class for a specific endpoint (classes Quiubas, Base and Network are always required).

Additionally, remember that in the directory dist/lib you can find the SDKs which are part of the requirements.

Classes available:

  • Quiubas
  • Sms
  • Balance
  • Base
  • Network
  • Keywords
  • Shortcode
  • TwoFactor
  • Mnp

Current version

The current version of the SDK is: 1.3.1.

Code example to use the SDK

Use this example if you downloaded the SDK

// Imports

// The library package import

import com.quiubas.api.*;

// Other imports

import java.util.Map;

import java.util.HashMap;

public class MyApp {

public static void main(String[] args) {

// Create an instance of the Quiubas class

Quiubas Quiubas = new Quiubas();

// Set the authentication information (API_KEY, API_SECRET)

Quiubas.setAuth("YOUR_API_KEY", "YOUR_API_SECRET");

// Lets create an example SMS, first create an instance of the Sms class

Sms Sms = new Sms();

//Then, we create a Map for the parameters

Map<String, String> data = new HashMap<>();

// Required parameters are "to_number" and "message"

data.put("to_number", "PHONE_NUMBER");

data.put("message", "Hello world");

// Now, lets send it.

try{

// If we don't have errors, we get a response as a JSONObject, so

// we can get, for example, the sms id and print it

System.out.println(Sms.send(data).getInt("id"));

}catch(Exception e){

// If we have errors, we show the error message

System.out.println(e.getMessage());

}

}

}