OTP API
Overview
Due to the security breaches caused by scammers and spammers have lost various important business details and eventually the business loss. Setting up an OTP API verification provides a business with the secure and safest environment to use mobile phones for shopping, business, financial transactions etc. OTP verification not only provides phone security but also keeps your personal computers or laptops secure.
Authentication Key
HTTP requests to the APIs are protected with user-based authentication key authkey. For every request, you would be needing this key. Please visit here for more info.
Create Campaign API
| Variable | Value | Explanation |
|---|---|---|
| auth | user auth key | This is the authkey which you generate from HTTP API |
| msisdn | 919xxxxx,919yyyyyyy,919zzzzz | You may have multiple numbers by comma separated |
| senderid | enter sender id | 1 : - for India enter 6 character approved sender id 2 : - for international enter 10 character sender id |
| message | type your own message. | 1 : - english message that you want to send 2 : - for unicode type=1 |
| countrycode | enter country code in which you want to send messgae | its an optional parameter if you do not include it ,system by default send message in India(91) Note:-don't include country code with mobile number |
http://localhost/API/sms-api.php?auth=XXXXX&msisdn=xxxxx&senderid=xxxxxx&message=xxxxx
Parameters
auth=XXX //your auth key
message=message // message you want to send //required if type=1
msisdn=xxxxx,xxxxxxx,xxxxxx //this is comma separated mobile numbers (max 1000)
senderid=your sender id // required
countrycode=enter country code // optional
type=1 // optional for unicode message
Response
{"status":"success","validcnt":1,"campg_id":22,"code":"100","ts":"2018-11-21 13:23:19"}
{"status":"failure","code":401,"desc":"No Auth","ts":"2018-11-20 08:34:04"}
{"status":"failure","code":402,"desc":"Invalid Auth","ts":"2018-11-20 13:03:48"}
{"status":"failure","code":405,"desc":"missing type parameter","ts":"2018-11-20 13:04:39"}
{"status":"failure","code":406,"desc":"Message Not Passed","ts":"2018-11-20 12:56:45"}
{"status":"failure","code":407,"desc":"You Don't have HTTP API permission","ts":"2018-11-20 13:04:39"}
{"status":"failure","code":408,"desc":"Invalid Sender ID","ts":"2018-11-20 13:04:39"}
{"status":"failure","code":410,"desc":"Msisdn Not Passed","ts":"2018-11-20 12:56:45"}
{"status":"failure","code":411,"desc":"MSISDN Limit Exceed","ts":"2018-11-20 12:56:45"}
{"status":"failure","code":412,"desc":"Insufficient Balance!","ts":"2018-11-20 12:56:45"}
{"status":"failure","code":413,"desc":"Sender Id Not Approved","ts":"2018-11-20 12:56:45"}
{"status":"failure","code":414,"desc":"Given country not active for your account please contact admin","ts":"2018-11-20 12:56:45"}
Sample Codes
$sender =XXXX;
$mob =XXXXX;
$auth=Your auth key;
$msg = urlencode("test");
$url = 'https://global.datagenit.com/API/sms-api.php?auth='.$auth.'&msisdn='.$mob.'&senderid='.$sender.'&message='.$msg.''; // API URL
SendSMS($url); // call function that return response with code
function SendSMS($hostUrl){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $hostUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_POST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1); // change to 1 to verify cert
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
//curl_setopt($ch, CURLOPT_USERPWD, "$username:$password");
$result = curl_exec($ch);
return $result;
}
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.IO;
using System.Net;
public void SMSSend()
{
WebClient client = new WebClient();
string baseurl = "https://global.datagenit.com/API/sms-api.php?auth=xxxxx&senderid=xxxxx&msisdn=xxxxxx&message=Hello";
Stream data = client.OpenRead(baseurl);
StreamReader reader = new StreamReader(data);
string s = reader.ReadToEnd();
data.Close();
reader.Close();
}
import http.client
conn = http.client.HTTPSConnection("global.datagenit.com")
headers = {
'cache-control': "no-cache"
}
conn.request("GET", "/API/sms-api.php?auth=xxxx&senderid=DATAGN&msisdn=xxxxx&message=Hello", headers=headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
sResponse = SMSSend(pno, message )
If right(sResponse,15) = "Send Successful" Then
'write your code here
End If
Function SMSSend (strPh,strMsg)
Dim msgResponse
Dim strRequest
Dim strUrl
msgResponse = ""
strPh=right(strPh,10)
If not IsNumeric(strPh) Or len(strPh) <> 10 Then
msgResponse = "Enter valid Mobile Number."
End If
If strMsg = "" Then
msgResponse = "Enter text message."
End If
strUrl = "global.datagenit.com/API/sms-api.php?"
strRequest = strRequest+"auth=xxxxx"
strRequest = strRequest+"&senderid=senderid"
strRequest = strRequest+"&msisdn="+strPh
strRequest = strRequest+"&message="+Server.URLEncode(strMsg)
strUrl = strUrl+strRequest
If msgResponse = "" Then
Dim oXML
Dim sPage
Err.Clear
On Error Resume Next
Set oXML = Server.CreateObject("Msxml2.XMLHTTP")
oXML.Open "get", strUrl , false
oXML.Send
msgResponse = oXML.ResponseText
Set oXML = Nothing
End If
SMSSend = msgResponse
If Err.Number <> 0 Then
SMSSend = "Problem on sending sms : "& Err.Description
End If
End Function
var request = require("request");
var options = { method: 'GET',
url: 'https://global.datagenit.com/API/sms-api.php',
qs:
{ auth: 'xxxxxx',
senderid: 'DATAGN',
msisdn: 'xxxxxxx',
message: 'Hello' },
headers:
{'cache-control': 'no-cache' } };
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLEncoder;
import java.util.Date;
public class SMSSend {
public static void main(String[] args)
{ try {
Date mydate = new Date(System.currentTimeMillis());
URL url = new URL("http://global.datagenit.com/API/sms-api.php?auth=xxxxx&senderid=xxxxx&msisdn=xxxxxx&message=Hello);
HttpURLConnection conn = (HttpURLConnection)url.openConnection();
conn.setRequestMethod("GET");
conn.setDoOutput(true);
conn.setDoInput(true);
conn.setUseCaches(false);
conn.connect();
BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
String line;
StringBuffer buffer = new StringBuffer();
while ((line = rd.readLine()) != null)
{
buffer.append(line).append("\n");
}
System.out.println(buffer.toString());
rd.close();
conn.disconnect();
}catch(Exception e)
{e
.printStackTrace();
}
}}
Note: Required javax.servlet.jar and jdom.jar to execute ( downloadable from internet,add to
classpath ).
Need Help
If you need any help related to the API integration then mail us on : Support@datagenit.com or call us : +91-9999-706-864
Our Team Will Help you related to your concern.