Request OTP Java (Android)
import java.io.*;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLEncoder;
public class Main {
public static void main(String[] args) {
String username = "&username=" + "YOU-HELLIO-MESSAGING-USERNAME";
String password = "&password=" + "YOU-HELLIO-MESSAGING-PASSWORD";
String senderId = "&senderId=" + "HellioSMS";
String mobile_number = "&mobile_number=" + "233242813656";
String tokenlength = "&tokenlength=" + "6"; // By default OTP lenght is 5 digits;
String timeout = "&timeout=" + "1"; //1 (Meaning 1 minute);
String recipient_email = "&recipient_email=" + "support@helliomessaging.com"; // The OTP Recipient email address);
String messageType = "&messageType=" + "0"; // Specify if you want to send OTP as a Flash Message or as a Text Message. 0 = Text Message and 1 = Flash Message, Or if you're sending messages in your native language e.g. Chinese, Arabic or languages that contains special characters, go with the following: 4 = Chinese or Arabic contents and 2 for other that contains special characters.;
String message = "&message=" + "This SMS Was Sent From A Java Code Sample"; // This field is optional;
// Prepare Url
URLConnection myURLConnection = null;
URL myURL = null;
BufferedReader reader = null;
// Base Endpoint
String baseUrl = "https://api.helliomessaging.com/v3/otp/send";
// Prepare parameter string
StringBuilder sbPostData = new StringBuilder(baseUrl);
sbPostData.append("&username=" + username);
sbPostData.append("&password=" + password);
sbPostData.append("&senderId=" + senderId);
sbPostData.append("&mobile_number=" + mobile_number);
sbPostData.append("&tokenlength=" + tokenlength);
sbPostData.append("&timeout=" + timeout);
sbPostData.append("&recipient_email =" + recipient_email );
sbPostData.append("&messageType =" + messageType );
sbPostData.append("&message=" + message);
// final string
baseUrl = sbPostData.toString();
try {
// prepare connection
myURL = new URL(baseUrl);
myURLConnection = myURL.openConnection();
myURLConnection.connect();
reader = new BufferedReader(new InputStreamReader(myURLConnection.getInputStream()));
// reading response
String response;
while ((response = reader.readLine()) != null)
// print response
System.out.println(response);
// finally close connection
reader.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
Response Object
[
{
"id": 138773,
"mobile_number": "233265515154",
"sender": "HellioSMS",
"sched_datetime": "2020-07-03 09:49:26",
"message": " Your OTP is 957052 and is valid for 1 minute(s)",
"total_cost": "0.014",
"status": "pending",
"messageType": "1",
"recipient_email": "support@helliomessaging.com",
"created_at": "2020-07-03 09:49:26"
}
]
Verify OTP Java (Android)
import java.io.*;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLEncoder;
public class Main {
public static void main(String[] args) {
String username = "&username=" + "YOU-HELLIO-MESSAGING-USERNAME";
String password = "&password=" + "YOU-HELLIO-MESSAGING-PASSWORD";
String mobile_number = "&mobile_number=" + "233242813656"; //The mobile number to which the otp was sent to
String otpCode = "&otpCode=" + "62352"; //You pass the OTP which was generated and send to the users phone. So basically you get it from the input you're asking the user to enter the sent OTP;
// Prepare Url
URLConnection myURLConnection = null;
URL myURL = null;
BufferedReader reader = null;
// Base Endpoint
String baseUrl = "https://api.helliomessaging.com/v3/otp/verify?";
// Prepare parameter string
StringBuilder sbPostData = new StringBuilder(baseUrl);
sbPostData.append("&username=" + username);
sbPostData.append("&password=" + password);
sbPostData.append("&mobile_number=" + mobile_number);
sbPostData.append("&otpCode=" + otpCode);
// final string
baseUrl = sbPostData.toString();
try {
// prepare connection
myURL = new URL(baseUrl);
myURLConnection = myURL.openConnection();
myURLConnection.connect();
reader = new BufferedReader(new InputStreamReader(myURLConnection.getInputStream()));
// reading response
String response;
while ((response = reader.readLine()) != null)
// print response
System.out.println(response);
// finally close connection
reader.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
Response Object
{
"responseCode": 200,
"message": "OTP Verified",
"status": "success"
}
Request OTP (PHP)
$baseUrl = 'https://api.helliomessaging.com/v3/otp/send';
$username = 'YOUR-HELLIO-MESSAGING-USERNAME';
$password = 'YOUR-HELLIO-MESSAGING-PASSWORD';
$senderId = 'YOUR-SENDERID'; // e.g HellioSMS (Max character for SenderId is 11 including space);
$mobile_number = 'MOBILE-NUMBER'; // e.g 233242813656;
$tokenlength = 6; //By default OTP lenght is 5;
$recipient_email = 'support@helliomessaging.com'; // The OTP Recipient email address ;
$messageType = 1; // Specify if you want to send OTP as a Flash Message or as a Text Message. 0 = Text Message and 1 = Flash Message, Or if you're sending messages in your native language e.g. Chinese, Arabic or languages that contains special characters, go with the following: 4 = Chinese or Arabic contents and 2 for other that contains special characters. ;
$timeout = 1; // The duration you wish to expire the generated OTP;
$message = 'YOUR-MESSAGE-HERE'; // This field is optional;
$params = array(
'username' => $username,
'password' => $password,
'senderId' => $senderId,
'mobile_number' => $mobile_number,
'tokenlength' => $tokenlength,
'timeout' => $timeout,
'recipient_email' => $recipient_email,
'messageType' => $messageType,
'message' => $message
);
// Send through CURL
$ch = curl_init($baseUrl);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// Process your response here
$result = curl_exec($ch);
echo var_export($result, true);
curl_close($ch);
Response Object
[
{
"id": 138773,
"mobile_number": "233265515154",
"sender": "HellioSMS",
"sched_datetime": "2020-07-03 09:49:26",
"message": " Your OTP is 957052 and is valid for 1 minute(s)",
"total_cost": "0.014",
"status": "pending",
"messageType": "1",
"recipient_email": "support@helliomessaging.com",
"created_at": "2020-07-03 09:49:26"
}
]
Verify OTP (PHP)
$baseUrl = 'https://api.helliomessaging.com/v3/otp/verify?';
$username = 'YOUR-HELLIO-MESSAGING-USERNAME';
$password = 'YOUR-HELLIO-MESSAGING-PASSWORD';
$mobile_number = 'THE-MOBILE-NUMBER-TO-WHICH-THE-OTP-WAS-SENT'; //Pass the mobile number to which the OTP was sent to;
$otpCode = 'THE-RECEIVED-OTP'; //Get the otp Received by the user here to validate it;
$params = array(
'username' => $username,
'password' => $password,
'mobile_number' => $mobile_number,
'otp' => $otpCode
);
// Send through CURL
$ch = curl_init($baseUrl);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// Process your response here
$result = curl_exec($ch);
echo var_export($result, true);
curl_close($ch);
Response Object
{
"responseCode": 200,
"message": "OTP Verified",
"status": "success"
}