Explore our Tutorials, Code Samples, SDKs and other resources to help you start building with EgoSms.

Developer Documentation

Sending SMS

HTTP SMS API

Tutorials
API Reference

JSON SMS API

Tutorials
API Reference

XML SMS API

Tutorials
API Reference

Balance Inquiry

HTTP BALANCE API

Tutorials
API Reference

JSON BALANCE API

Tutorials
API Reference

XML BALANCE API

Tutorials
API Reference

Transaction Status

Middleware

Data Conversions to JSON

DELIVERY REPORT

Tutorials
API Reference
				
					
package trial;

import java.io.BufferedReader;

import java.io.InputStreamReader;

import java.io.OutputStream;

import java.net.HttpURLConnection;

import java.net.URL;

public class textConvert {

public static void main(String[] args) {

try

{

// URL for the API content

URL url = new URL("https://demo20.pahappademo.net/middleware/plaintexttojson.php");

// Create an HTTPURL Conncetion

HttpURLConnection connection = (HttpURLConnection)url.openConnection();

connection.setRequestMethod("POST");

connection.setRequestProperty("Content-Type", "application/text");

connection.setDoOutput(true);

// Plain Text data to send

String txtData = "method = sendsms\r\n"

"userdata = username:john,password:123\r\n"

"msgdata = number:0868987654,message:hi,senderid:ego";

// Send text data

try(OutputStream os = connection.getOutputStream())

{

byte[] input = txtData.getBytes("utf-8");

os.write(input, 0, input.length);

}

// GET THE RESPONSE

int responseCode = connection.getResponseCode();

if (responseCode == HttpURLConnection.HTTP_OK)

{

// READ THE RESPONSE

try (BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream())))

{

String inputLine;

StringBuilder response = new StringBuilder();

while ((inputLine = in.readLine()) != null)

{

response.append(inputLine);

}

// JSON response

String jsonResponse = response.toString();

System.out.println("JSON Response: " + jsonResponse);

}

}

else

{

System.out.println("Request failed with response code :" + responseCode);

}

}

catch (Exception e)

{

}

}

}