Example code for SMS integration in language JAVA

Send SMS - REST API - JSON

            
HttpResponse<String> response = Unirest.post("https://api.labsmobile.com/json/send")
  .header("Content-Type", "application/json")
  .basicAuth("myusername","mypassword")
  .header("Cache-Control", "no-cache")
  .body("{\"message\":\"Text of the SMS message\", \"tpoa\":\"Sender\",\"recipient\":[{\"msisdn\":\"12015550123\"},{\"msisdn\":\"447400123456\"},{\"msisdn\":\"5212221234567\"}]}")
  .asString();

Credit inquiry - REST API - JSON

            
HttpResponse<String> response = Unirest.get("https://api.labsmobile.com/json/balance")
  .basicAuth("myusername","mypassword")
  .header("Cache-Control", "no-cache")
  .asString();

Send SMS - HTTP/GET

                
import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;

...

HttpURLConnectionExample http = new HttpURLConnectionExample();

String url = "http://api.labsmobile.com/get/send.php?username=[X]&password=[X]&msisdn=34609036253&sender=SENDER&message=This+is+the+message";

URL obj = new URL(url);
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
con.setRequestMethod("GET");
con.setRequestProperty("User-Agent", "Mozilla/5.0");
int responseCode = con.getResponseCode();

BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
String inputLine;
StringBuffer response = new StringBuffer();

while ((inputLine = in.readLine()) != null) {
	response.append(inputLine);
}
in.close();
System.out.println(response.toString());

Credit inquiry - HTTP/GET

                
import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;

...

HttpURLConnectionExample http = new HttpURLConnectionExample();

String url = "http://api.labsmobile.com/get/balance.php?username=[X]&password=[X]";

URL obj = new URL(url);
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
con.setRequestMethod("GET");
con.setRequestProperty("User-Agent", "Mozilla/5.0");
int responseCode = con.getResponseCode();

BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
String inputLine;
StringBuffer response = new StringBuffer();

while ((inputLine = in.readLine()) != null) {
	response.append(inputLine);
}
in.close();
System.out.println(response.toString());
  • contact form support

    Sign up!

    Create a user account and send your SMS messages in seconds. You will have all the functionalities and benefits in the same platform.

    Send from API and manage your account with our online application WebSMS.

    Create new account
  • Hey Petit, Services for rural accommodation recommends LabsMobile

    SMS confirmation and reservation reminders for rural accommodation using an online portal.

    Watch more reviews
  • dashboard aplicación online

    Maximum reliability at the best price

    At LabsMobile we only offer direct routes of maximum reliability and quality. Enjoy our platform and all our services for the price of an SMS.

    Pay ONLY for sent messages.

    Check our rates
  • dashboard aplicación online

    Need more info? Contact us!

    Our technical department has professionals with years of experience and we have made multiple integrations.

    We guide and help you through the process.

    Request technical support
  • Buy credits or set up automatic top-ups

    This tutorial explains how to reload credits step by step in your WebSMS account and also how to configure automatic reloads so that your account never runs out of credits.

    Ir al tutorial
loader