array(
CURLOPT_URL => "http://sms.bulksmslab.com/SMSApi/send",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "userid=XXXX&password=xxxxx&mobile=91xxxxxxxxxx&msg=Hello+World%21+This+is+a+test+message%21&senderid=SENDER&msgType=text&dltEntityId=xxxxxxxxxxxxx&dltTemplateId=xxxxxxxxxxxxx&duplicatecheck=true&output=json&sendMethod=quick",
CURLOPT_HTTPHEADER => array(
"apikey: somerandomuniquekey",
"cache-control: no-cache",
"content-type: application/x-www-form-urlencoded"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
curl_init();
curl_setopt_array($curl,array(
CURLOPT_UR "http://sms.bulksmslab.com/SMSApi/send?userid=xxx&password=xxxxx&mobile=91xxxxxxxxxx&msg=Hello+World%21+This+is+a+test+message%21&senderid=xxxx&msgType=text&dltEntityId=xxxxxxxxxxxxx&dltTemplateId=xxxxxxxxxxxxx&duplicatecheck=true&output=json&sendMethod=quick",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array(
"cache-control: no-cache"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
package test;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.util.EntityUtils;
public class SendMessage {
public static void main(String[] args) throws ClientProtocolException, IOException {
String ServerDomain = "http://sms.bulksmslab.com/SMSApi/send";
String ApiEndPoint = "/send";
HttpClient httpclient = HttpClients.createDefault();
HttpPost httppost = new HttpPost(ServerDomain + ApiEndPoint);
// Request parameters and other properties.
List params = new ArrayList (2);
params.add(new BasicNameValuePair<("userid", "admin"));<
params.add(new BasicNameValuePair<("password", "YourPassword"));<
params.add(new BasicNameValuePair<("text", "Hello World"));<
params.add(new BasicNameValuePair<("type", "text"));<
params.add(new BasicNameValuePair<("time", "2018-09-16 13:24:00"));<
params.add(new BasicNameValuePair<("senderid", "SENDER"));
params.add(new BasicNameValuePair<("test", "false"));<
params.add(new BasicNameValuePair<("dltEntityId", "xxxxxxxxxxxxx"));<
params.add(new BasicNameValuePair<("dltTemplateId", "xxxxxxxxxxxxx"));<
params.add(new BasicNameValuePair<("duplicatecheck", "true"));<
params.add(new BasicNameValuePair<("output", "json"));<
params.add(new BasicNameValuePair<("mobile", "91xxxxxxxxxx"));<
httppost.setEntity(new UrlEncodedFormEntity(params, "UTF-8"));
// Execute and get the response.
HttpResponse response = httpclient.execute(httppost);
HttpEntity entity = response.getEntity();
System.out.println("StatusCode: " + response.getStatusLine().getStatusCode());
if (entity != null) {
try (InputStream instream = entity.getContent()) {
System.out.println(EntityUtils.toString(entity, "utf-8"));
}
}
}
}
import java.io.*;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLEncoder;
public class SMSGateway {
public static void main(String[] args) {
// Your apikey key
String apiKey = "YourApiKey";
// OR
String userId = "xxxx";
String password = "YourPassword";
// Message type text/unicode/flash
String msgType = "text";
// Multiple mobiles numbers separated by comma
String mobile = "91999xxxxxxx";
// Your approved sender id
String senderId = "SENDER";
// Your message to terminate, URLEncode the content
String msg = "This is a test message in Java";
// DLT PE ID
String dltEntityId = "xxxxxxxxxxxxx";
// DLT Template ID
String dltTemplateId = "xxxxxxxxxxxxx";
// response format
String output = "json";
// Prepare Url
URLConnection myURLConnection = null;
URL myURL = null;
BufferedReader reader = null;
// URL encode message
String urlencodedmsg = "";
try {
urlencodedmsg = URLEncoder.encode(msg, "UTF-8");
} catch (UnsupportedEncodingException e1) {
// TODO Auto-generated catch block
System.out.println("Exception while encoding msg");
e1.printStackTrace();
}
// API End Point
String mainUrl = "http://sms.bulksmslab.com/SMSApi/send?";
// API Paramters
StringBuilder sendSmsData = new StringBuilder(mainUrl);
sendSmsData.append("apikey=" + apiKey);
sendSmsData.append("&userid=" + userId);
sendSmsData.append("&password=" + password);
sendSmsData.append("&type=" + msgType);
sendSmsData.append("&mobile=" + mobile);
sendSmsData.append("&senderid=" + senderId);
sendSmsData.append("&text=" + urlencodedmsg);
sendSmsData.append("&dltEntityId=" + dltEntityId);
sendSmsData.append("&dltTemplateId=" + dltTemplateId);
sendSmsData.append("&output=" + output);
// final string
mainUrl = sendSmsData.toString();
try {
// prepare connection
myURL = new URL(mainUrl);
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();
}
}
}
curl -X POST \
http://sms.bulksmslab.com/SMSApi/send \
-H 'Content-Type: application/json' \
-d '{
"userid": "xxxx",
"password" : "XXXXX",
"senderid": "SENDER",
"msgType": "text",
"dltEntityId": "xxxxxxxxxxxxx",
"dltTemplateId": "xxxxxxxxxxxxx",
"duplicatecheck": "true",
"sendMethod": "quick"
"sms": [
{
"mobile": ["9999999991"],
"msg": "hello world again"
},
{
"mobile": ["9999999999"],
"msg": "Final last msg"
}
]
}'
Copyright © 2021 Reserved By Digital Sanchar