BD Bulk SMSLogin BD Bulk SMSRegister

BD Bulk SMS API (English Manual)


API Link
SMS Sending API URL (HTML Output): http://api.greenweb.com.bd/api.php
Or,
SMS Sending API URL (JSON Output): http://api.greenweb.com.bd/api.php?json
SSL Version: You can use https protocol

Generate Token ( From SMS panel): https://gwb.li/token
Required Parameters ( For Sending SMS): message, to, token
Request Method: POST or GET
Other API Usages:

URL: http://api.greenweb.com.bd/g_api.php (html output)
URL: http://api.greenweb.com.bd/g_api.php?json  (JSON)

Check Balance: http://api.greenweb.com.bd/g_api.php?token=yourtokencodehere&balance
Check Balance (JSON Format): http://api.greenweb.com.bd/g_api.php?token=yourtokencodehere&balance&json

Check SMS Rate: http://api.greenweb.com.bd/g_api.php?token=yourtokencodehere&rate

Total Sent SMS Stats Using Token: http://api.greenweb.com.bd/g_api.php?token=yourtokencodehere&tokensms

Total Sent SMS Stats From Your Account: http://api.greenweb.com.bd/g_api.php?token=yourtokencodehere&totalsms

Total Sent SMS Monthly (within current month) Stats From Your Account: http://api.greenweb.com.bd/g_api.php?token=yourtokencodehere&monthlysms

Total Sent SMS Monthly (within current month) Stats From The token: http://api.greenweb.com.bd/g_api.php?token=yourtokencodehere&tokenmonthlysms

Total Sent SMS in Any Month (Write month in m-Y format. Ex: 01-2024) From Your Account: http://api.greenweb.com.bd/g_api.php?token=yourtokencodehere&monthlysms=10-2024
Total Sent SMS in Any Month (Write month in m-Y format. Ex: 01-2024) From Specific Token: http://api.greenweb.com.bd/g_api.php?token=yourtokencodehere&tokenmonthlysms=10-2024 SMS Validity: http://api.greenweb.com.bd/g_api.php?token=yourtokencodehere&expiry Everything Together: http://api.greenweb.com.bd/g_api.php?token=yourtokencodehere&expiry&rate&tokensms&totalsms&monthlysms&tokenmonthlysms Everything Together (json): http://api.greenweb.com.bd/g_api.php?token=yourtokencodehere&expiry&rate&tokensms&totalsms&monthlysms&tokenmonthlysms&json

Demo Token: 1234567890123456789

Request Methods: POST (recommended) & GET
Parameters: to, message, token
You can use this API in GET and POST method. First Login Your SMS Portal and Generate Access Token from the below link
https://sms.greenweb.com.bd/index.php?ref=gen_token
If you dont have any account you can use this demo token for integrating purposes: 1234567890123456789 It will not send any SMS but will return response like the real token, so for integrating our API with your software you can use it. Please replace this demo token with the real one after completing your integrating.
Request Method & Parameters:
token = Generate it from sms panel
to = Recipient Numbers । Format must be +8801xxxxxxxxx or 01xxxxxxxxx (Bangladeshi Number format)
message = whatever you want to send
For Example:
POST Method

<form action="http://api.greenweb.com.bd/api.php" method="post">
<input type="text" name="token" placeholder="token" />
<input type="text" name="to" placeholder="+8801xxxxxxxxx,+8801xxxxxxxxx" />
<textarea class="span11" name="message" id="message" style="position: relative; left: 4%;" ></textarea>
<button type="submit" name="submit" class="btn btn-success btn-large">Send Message</button>
</form>
Get Method:
http://api.greenweb.com.bd/api.php?token=tokencodehere&to=017xxxxxxxx,015xxxxxxxx&message=my+message+is+here
If you're using GET METHOD you have to URL ENCODE message text. For URL Encoding you can use rawurlencode() in php । if its javascript you can use encodeURI()

JSON Data Format:

{
  "smsdata": [
    {
      "to": "01623505818",
      "message": "string"
    },
   {
      "to": "01615050504",
      "message": "test"
    }
  ],
  "token": "1234567890123456789"
}

Send Bulk SMS From any HTML Form

Generate Token: https://sms.greenweb.com.bd/index.php?ref=gen_token

<form action="http://api.greenweb.com.bd/api.php" method="post">
<input type="text" name="token" placeholder="token" />
<input type="text" name="to" placeholder="+8801xxxxxxxxx,+8801xxxxxxxxx" />
<textarea class="span11" name="message" id="message" style="position: relative; left: 4%;" ></textarea>
<button type="submit" name="submit" class="btn btn-success btn-large">Send Message</button>
</form>

Process bulk SMS return response

Token Generate করুন : https://sms.greenweb.com.bd/index.php?ref=gen_token

By Default Our  API Retun Line by Line seperated html response । You can take each line in array and match Ok: for success and for the error you can match  Error: word । For example:

Ok: SMS Sent Successfully To +8801xxxxxxxxx
Error: +8801xxxxxxxxx Invalid Number ! You got the above response now take it in an array $smsresultarray = preg_split('/\r\n|\r|\n/', $smsresult); now process the array foreach($smsresultarray as $result) { $status = mb_substr($result, 0, 2); if ($status == 'Ok') { //sms successfully sent do whatever you want echo $result; } else { //failed to sent do whatever you want echo $result; } } You can get JSON Response by input &json at the end of the url like this http://api.greenweb.com.bd/api.php?json For example : <?php $to = "017xxxxxxx,+88016xxxxxxx"; $token = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; $message = "Test SMS using API"; //Put &json in here -> $url = "http://api.greenweb.com.bd/api.php?json"; $data= array( 'to'=>"$to", 'message'=>"$message", 'token'=>"$token", 'json'=>"1", ); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL,$url); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($ch, CURLOPT_ENCODING, ''); curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data)); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $smsresult = curl_exec($ch); //Result echo $smsresult; //Error Display echo curl_error($ch); ?> Now you'll get output like this : [ { "to": "+8801xxxxxxx", "message": "test sms", "status": "SENT", "statusmsg": "SMS Sent Successfully To +8801xxxxxxx" }, { "to": "+8801xxxxxxx", "message": "test sms", "status": "FAILED", "statusmsg": "+8801xxxxxxx Invalid Number" } ] How to process it in php? $smsresult = json_decode($smsresult); foreach ($smsresult as $result) { if ($result->status == "SENT") { echo "SMS sent successfully"; echo $result->to; echo $result->status; echo $result->statusmsg; } else { echo "Failed to send"; echo $result->to; echo $result->status; echo $result->statusmsg; } }
(One to one/One to many)

Send Same SMS to Multiple Recipient

Generate Token : https://sms.greenweb.com.bd/index.php?ref=gen_token

<?php        
$to = "017xxxxxxx,+88016xxxxxxx";
$token = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
$message = "Test SMS using API";

$url = "http://api.greenweb.com.bd/api.php?json";


$data= array(
'to'=>"$to",
'message'=>"$message",
'token'=>"$token"
); 
$ch = curl_init(); 
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_ENCODING, '');
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$smsresult = curl_exec($ch);

//Result
echo $smsresult;

//Error Display
echo curl_error($ch);

?>
			
For sending sms you need three data. 1. to (it is the receiver phone number), 2. message (it is the text you want to send) 3. token (you have to generate it from the panel, it will works as a key)
(One to one/One to many)

Send SMS to one/many using PHP and Database

Generate token : https://sms.greenweb.com.bd/index.php?ref=gen_token
Example: to send same text to one or multiple recipients
		
<?php 

//Take Data from your database in your own way in a loop

$dblink = mysqli_connect("localhost", "dbusername", "dbpassword", "dbname");
/* If connection fails throw an error */
if (mysqli_connect_errno()) {
    echo "Could  not connect to database: Error: ".mysqli_connect_error();
    exit();
}
$sqlquery = "SELECT number FROM table_name";
if ($result = mysqli_query($dblink, $sqlquery)) {
    /* fetch associative array */
    while ($row = mysqli_fetch_assoc($result)) {
	$number = $row["number"];
	$to = "$number,$to";
    }
} 

// We got all numbers in a string called $to now we will send sms 

$token = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
$message = "Test SMS using API";

$url = "http://api.greenweb.com.bd/api.php";


$data= array(
'to'=>"$to",
'message'=>"$message",
'token'=>"$token"
); 
$ch = curl_init(); 
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_ENCODING, '');
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$smsresult = curl_exec($ch);

//Result
echo $smsresult;

//Error Display
echo curl_error($ch);

?>
			
(Many to Many)

Send Different Text to Different numbers simultaneously

Generate Token : https://sms.greenweb.com.bd/index.php?ref=gen_token
Json Format (এখানে smsdata তে নাম্বার ও ম্যাসেজ ল্যুপে থাকবে এবং token এ SMS প্যানেল থেকে token তৈরি করে দিতে হবে।:

{
  "smsdata": [
    {
      "to": "+8801xxxxxxx",
      "message": "বাংলা ম্যাসেজ"
    },
    {
      "to": "01xxxxxxx",
      "message": "test"
    }
  ],
  "token": "replace_it_with_your_token_code"
}

test this code : https://reqbin.com/bwdocgdo
php sample code using json data:

<?php
  $url = "https://api.bdbulksms.net/api.php?json";
  $data = json_encode([
    'token' => 'Replace_it_with_your_token',
    'smsdata' => [
        [
            'to' => '+8801xxxxxxx',
            'message' => 'বাংলা ম্যাসেজ',
        ],
        [
            'to' => '01xxxxxxx',
            'message' => 'English sms test',
        ],
    ],
], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);   

  $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL, $url);
  curl_setopt($ch, CURLOPT_POST, 1);
  curl_setopt($ch, CURLOPT_ENCODING, '');
  curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
  curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  $response = curl_exec($ch);
 
  //response
  echo $response;
?>
Alternative Method:

JSON Format: [{"to":"+8801xxxxxxxxx","message":"firstsmstest"},{"to":"018xxxxxxxxxxx","message":"secondmesssagehere"}] 

(Your message must be urlencoded or rawurldecoded) 

Live preview:http://jsfiddle.net/greenwebbd/hp2Lr460/embedded/result 
Code:http://jsfiddle.net/greenwebbd/hp2Lr460/embedded/html

Parameters:
token = Generate from above link
smsdata = valid json data containing to and message text
Sample PHP Code:

<?php
  $url = "https://api.greenweb.com.bd/api.php?json";
  $data = [
    "token" => "your token here",
    "smsdata" => json_encode( 
	[
      [
        "to" => "88017xxxxxxxx",
        "message" => "testsms one"
      ],
      [
        "to" => "88018xxxxxxxx",
        "message" => "test sms two"
      ]
    ], 
	JSON_UNESCAPED_UNICODE)
  ];
  
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL, $url);
  curl_setopt($ch, CURLOPT_POST, 1);
  curl_setopt($ch, CURLOPT_ENCODING, '');
  curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
  curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  $response = curl_exec($ch);
 
  //response
  echo $response;
?>
Using Database and php:


<?php 
$json_smsdata = [];

// Take Data from database using loop

$dblink = mysqli_connect("localhost", "dbusername", "dbpassword", "dbname");
/* If connection fails throw an error */
if (mysqli_connect_errno()) {
    echo "Could  not connect to database: Error: ".mysqli_connect_error();
    exit();
}

//you can max set limit here (if you want)
$sqlquery = "SELECT name,number FROM table_name LIMIT 1000";
if ($result = mysqli_query($dblink, $sqlquery)) {
    /* fetch associative array */
    while ($row = mysqli_fetch_assoc($result)) {
       $name = $row["name"];
       $number = $row["number"];

// We got name and number now we will format our text

$message = rawurlencode("Hi $name,
your message 
Regards
bdsms.net
");

$json_smsdata[]= ['to'=>$number,'message'=>$message];
	  }
	  
}

$smsdata = json_encode($json_smsdata);

// $smsdata containts our json encoded data 
//now send it
			
$token = "yourtokenhere_xxxxxxxxxxxxxxxxxxx";
$smsdata = $smsdata;

$url = "https://api.greenweb.com.bd/api.php";


$data= array(
'smsdata'=>"$smsdata",
'token'=>"$token"
); 
$ch = curl_init(); 
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_ENCODING, '');
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$smsresult = curl_exec($ch);

//Result
echo $smsresult;

//Error Display
echo curl_error($ch);
?>
			
To prevent abuse use Time limit, Ip Limit, Google/Cloudflare Captcha and csrf protection. Please becareful about mitm attack Generate Token: https://sms.greenweb.com.bd/index.php?ref=gen_token

<?php

    <?php
  // Start the session
  session_start();
  //give your token here
  $token = "xxxxxxxxxxxxxxxxxxxxxxxxxx";
  
  
  
function GetRealUserIp($default = NULL, $filter_options = 12582912) {
	$HTTP_CLIENT_IP = "";
    $HTTP_X_FORWARDED_FOR =  $_SERVER["HTTP_X_FORWARDED_FOR"];
	if (!empty($_SERVER['HTTP_CLIENT_IP'])) { $HTTP_CLIENT_IP = $_SERVER['HTTP_CLIENT_IP']; }
    $HTTP_CF_CONNECTING_IP = $_SERVER["HTTP_CF_CONNECTING_IP"];
    $REMOTE_ADDR = $_SERVER["REMOTE_ADDR"];

    $all_ips = explode(",", "$HTTP_X_FORWARDED_FOR,$HTTP_CLIENT_IP,$HTTP_CF_CONNECTING_IP,$REMOTE_ADDR");
    foreach ($all_ips as $ip) {
        if ($ip = filter_var($ip, FILTER_VALIDATE_IP, $filter_options))
            break;
    }
    return $ip?$ip:$default;
}

$ip = GetRealUserIp();  
  
  
  
echo "<center>";
if (isset($_POST['code'])) { 

//csrf protection
if (($_SESSION["csrftoken"]) != ($_POST['csrftoken'])) {
echo "OTP Abuse detected ! Please refresh the page and try again !";	
	exit();
}

  //check for matching
  if ($_SESSION["otp"] == $_POST['code']) {
  echo "You have verified your mobile number successfully</br>";
  $_SESSION['verified'] = "1";
  //Reset otp request limit
  $_SESSION[$ip] = "0";
 
} else {
  echo "You have entered wrong otp code, try again later.";
  }
}



if ((isset($_SESSION['verified'])) AND ($_SESSION['verified'] == '1')) {

//you can post your page content here  or below the page.


} else {

if(isset($_POST['otp'])) {
//check csrf for protection if (($_SESSION["csrftoken"]) != ($_POST['csrftoken'])) { echo "OTP Abuse detected ! Please refresh the page and try again !"; exit(); } else { $csrftoken = $_POST['csrftoken']; } // Check how many times an otp requested from an ip and take precautions if its high if ($_SESSION[$ip] > "5") { echo "You're allowed to request otp for 5 times per session ! Your request is blocked."; exit(); } // Generate Random 5 digits otp $code = substr(md5(mt_rand()), 0, 5); //send otp to mobile via api $to = preg_replace("|[^0-9 \+\/]|", '', $_REQUEST['number']); //message text $message = "(YourCompanyName) আপনার ওটিপি কোড: $code @youdomainname, #$code"; $url = "http://api.greenweb.com.bd/api.php"; $data= array( 'to'=>"$to", 'message'=>"$message", 'token'=>"$token" ); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL,$url); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($ch, CURLOPT_ENCODING, ''); curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data)); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $smsresult = curl_exec($ch); $result = mb_substr($smsresult, 0, 2); if ($result == 'Ok') {
//Per ip OTP Limit if (isset($_SESSION[$ip])) { $_SESSION[$ip] = ($_SESSION[$ip] + 1); } else { $_SESSION[$ip] = "1"; } echo "Otp code is successfully sent to your mobile, you may have to wait upto 5 min to receive your code";
// save otp code on the session $_SESSION["otp"] = $code;
//show code input form echo " Enter the verification code below </br> <form action='' method='POST'> <input type='text' name='code'> <input type='hidden' name='csrftoken' value='$csrftoken' > <button type='submit' value='code' name='otp'>Verify</button> </form>"; exit(); } else { echo "Failed to send Otp. Please try again after sometime"; exit(); } } else { //generate csrf token it's require to protect your otp sms form from the abusers $csrftoken = substr(md5(mt_rand()), 0, 15); $_SESSION["csrftoken"] = $csrftoken; echo " Enter your mobile number to receive OTP code </br> <form action='' method='POST'> <input type='text' name='number'> <input type='hidden' name='csrftoken' value='$csrftoken' > <button type='submit' value='otp' name='otp'>Get Otp</button> </form>"; exit(); }
//it's not required but for extra safety exit(); } ?>

Send Bulk SMS From Google Spreadsheet

Generate Token: https://sms.greenweb.com.bd/index.php?ref=gen_token

function myFunction(sms){

var to = "016150505xx";
var row = 1; //grab cell data from row 1 
var col = 1; //grab cell data from column 1

var gwcelldata = SpreadsheetApp.getActiveSheet().getRange(row, col).getValue(); //get active sheet data

var sms = encodeURI("Test Message"+gwcelldata);
var url = "https://sms.greenweb.com.bd/api.php?token=yourtokenhere&to="+to+"&message="+sms+"&submit";
var response = UrlFetchApp.fetch(url);
Logger.log(response);
}
	
	
For more information check: https://developers.google.com/apps-script/reference/spreadsheet/sheet

Send SMS From asp Classic (.asp or .aspx File)

Generate Token: https://sms.greenweb.com.bd/index.php?ref=gen_token

<% 
        apiurl = "http://api.greenweb.com.bd/api.php?"
        message = "Hello World"
        message = Server.urlencode(message)
        mobile = "017xxxxx,016xxxxx"
        '11 digit number
        url = apiurl & "token=" & token & "&to=" & mobile & "&message=" & message
        set xmlhttp = CreateObject("MSXML2.ServerXMLHTTP")
        xmlhttp.open "POST", url, false
        'use GET for get method
        xmlhttp.send ""
        msg = xmlhttp.responseText
        response.write(msg)
        set xmlhttp = nothing
    %>
		

Send Bulk SMS From C# (Example 1, recommended)

Generate Token : https://sms.greenweb.com.bd/index.php?ref=gen_token
Test this code: http://volatileread.com/utilitylibrary/snippetcompiler?id=117220

using System;
using System.Collections.Generic;
using System.Text;
using System.Net;
using System.IO;

namespace GreenwebBDAPI{
    class Program{
        static void Main(string[] args){
        string result = "";
            WebRequest request = null;
            HttpWebResponse response = null;
            try{
                String to = "016xxxxxxxx,017xxxxx"; //Recipient Phone Number multiple number must be separated by comma
                String token = "entertokencodehere"; //generate token from the control panel
                String message = System.Uri.EscapeUriString("my messages"); //do not use single quotation (') in the message to avoid forbidden result
                String url = "http://api.greenweb.com.bd/api.php?token=" + token + "&to=" + to + "&message=" + message;
                request = WebRequest.Create(url);
            
                // Send the 'HttpWebRequest' and wait for response.
                response = (HttpWebResponse) request.GetResponse();
                Stream stream = response.GetResponseStream();
                Encoding ec = System.Text.Encoding.GetEncoding("utf-8");
                StreamReader reader = new
                System.IO.StreamReader(stream, ec);
                result = reader.ReadToEnd();
                Console.WriteLine(result);
                reader.Close();
                stream.Close();
            } catch (Exception exp){
                Console.WriteLine(exp.ToString());
            } finally {
                if (response != null)
                    response.Close();
            }
        }
    }
}
	

Send Bulk SMS From C# (Example 2)

Token Generate করুন : https://sms.greenweb.com.bd/index.php?ref=gen_token

using System.Net.Http;

Setup:

It is recommended to instantiate one HttpClient for your application's lifetime and share it.

private static readonly HttpClient client = new HttpClient();

POST:

var values = new Dictionary
{
   { "token", "yourtokenhere" },
   { "to", "016xxxxxxxxx" },
{ "message", "test" }
};

var content = new FormUrlEncodedContent(values);

var response = await client.PostAsync("http://api.greenweb.com.bd/api.php?", content);

var responseString = await response.Content.ReadAsStringAsync();
	

Send Bulk SMS From C# (Example 2)

Generate Token : https://sms.greenweb.com.bd/index.php?ref=gen_token

Newer library sporting a fluent API and testing helpers. HttpClient under the hood. Portable. Available via NuGet.

using Flurl.Http;

POST

var responseString = await "http://api.greenweb.com.bd/api.php?"
    .PostUrlEncodedAsync(new { token = "yourtokencodehere", to = "015xxxxxxx", message = "my message" })
    .ReceiveString();
	

Send BULK SMS From Android APP

Generate Token : https://sms.greenweb.com.bd/index.php?ref=gen_token


String token = "YourTokenCodeHere";

//Single or Multiple mobiles numbers separated by comma
String to = "017xxxxxxxxx,016xxxxxxx";

//Your message to send, Add URL encoding here.
String textmessage = "my message is here";

URLConnection myURLConnection=null;
URL myURL=null;
BufferedReader reader=null;

//encode the message content
String encoded_message=URLEncoder.encode(textmessage);
String apiUrl="http://api.greenweb.com.bd/api.php?";

StringBuilder sgcPostContent= new StringBuilder(apiUrl);
sgcPostContent.append("token="+token);
sgcPostContent.append("&to="+to);
sgcPostContent.append("&message="+encoded_message);

apiUrl = sgcPostContent.toString();
try
{
    //prepare connection
    myURL = new URL(apiUrl);
    myURLConnection = myURL.openConnection();
    myURLConnection.connect();
    reader= new BufferedReader(new InputStreamReader(myURLConnection.getInputStream()));

    //read the output
    String output;
    while ((output = reader.readLine()) != null)
    //print output
    Log.d("OUTPUT", ""+output);

    //Close connection
    reader.close();
}
catch (IOException e)
{
    e.printStackTrace();
}
	

Send BULK SMS From VB.NET

Token Generate করুন : https://sms.greenweb.com.bd/index.php?ref=gen_token

 Imports System.Web
    Imports System.IO
    Imports System.Net
    Imports System.Text
    Imports System.Resources
    
    Public Class greenwebApi
     
        Public Function greenwebApi()
            Dim token = "YourTokenCodeHere"
          
            Dim message = "Hello World"
            Dim mobile = "017xxxxxxxx"
            Dim url As String = "http://api.greenweb.com.bd/api.php?"
            Dim strPost As String
           
            strPost = url + "token=" + token _
            + "&to=" + mobile _
            + "&message=" + WebUtility.UrlEncode(message) 
            
            Dim request As WebRequest = WebRequest.Create(strPost)
            request.Method = "POST"
            Dim byteArray As Byte() = Encoding.UTF8.GetBytes(strPost)
            request.ContentType = "application/x-www-form-urlencoded"
            request.ContentLength = byteArray.Length
            Dim dataStream As Stream = request.GetRequestStream()
            dataStream.Write(byteArray, 0, byteArray.Length)
            dataStream.Close()
            
            Dim response As WebResponse = request.GetResponse()
            dataStream = response.GetResponseStream()
            Dim reader As New StreamReader(dataStream)
            Dim responseFromServer As String = reader.ReadToEnd()
            Console.WriteLine(responseFromServer)
            Console.ReadLine()
            
            reader.Close()
            dataStream.Close()
            response.Close()
            
            If responseFromServer.Length > 0 Then
                Return responseFromServer
            Else
                Return CType(response, HttpWebResponse).StatusDescription
            End If
        End Function
    End Class

	

Send BULK SMS From Visual Basic 6

Token Generate করুন : https://sms.greenweb.com.bd/index.php?ref=gen_token
Download Sample Project: https://bdbulksms.net/download/vb6.zip

 Private Sub Command1_Click()

    Dim DataToSend As String
    Dim objXML As Object
    Dim message As String
    Dim token As String
    Dim smsto As String
    Dim URL As String

'Set Your Token Here. Generate it from the control panel
token = "xxxxxxxxxxxxxxxxxxxx"

'set/declare your recipient number here
smsto = "01xxxxxxxxxxx"

'Set your Message here
message = URLEncode(" Hello World This is Greenweb BD ")

' do not change anything below
URL = "http://api.greenweb.com.bd/api.php?"

Set objXML = CreateObject("Microsoft.XMLHTTP")
objXML.Open "POST", URL, False
objXML.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"

objXML.send "token=" + token + "&to=" + smsto + "&message=" + message

'response box start, You can remove the response code from here
 If Len(objXML.responseText) > 0 Then
        MsgBox objXML.responseText

 End If
'response end remove upto this if you want

End Sub

Function URLEncode(ByVal Text As String) As String
    Dim i As Integer
    Dim acode As Integer
    Dim char As String

    URLEncode = Text

    For i = Len(URLEncode) To 1 Step -1
        acode = Asc(Mid$(URLEncode, i, 1))
        Select Case acode
            Case 48 To 57, 65 To 90, 97 To 122
                ' don't touch alphanumeric chars
            Case 32
                ' replace space with "+"
                Mid$(URLEncode, i, 1) = "+"
            Case Else
                ' replace punctuation chars with "%hex"
                URLEncode = Left$(URLEncode, i - 1) & "%" & Hex$(acode) & Mid$ _
                    (URLEncode, i + 1)
        End Select
    Next

End Function


	

Send BULK SMS From ORACLE FORM BUILDER / ORACLE

Token Generate করুন : https://sms.greenweb.com.bd/index.php?ref=gen_token
Take two text items and one button, Give text items name TO and MESSAGE and triger button WHEN-BUTTON-PRESSED with the following code

 DECLARE
	smsto varchar(5000) := :new.to;
	message varchar(5000) := Utl_Url.escape(:new.message, TRUE);
  req   UTL_HTTP.REQ;
  resp  UTL_HTTP.RESP;
  value VARCHAR2(5024); 
  v_url VARCHAR2(200) := 'http://api.greenweb.com.bd/api.php';
 
  v_param VARCHAR2(5000) := 'token=yourtoken&to=' || smsto || '&message=' || message || '';
  v_param_length NUMBER := length(v_param);
BEGIN
  req := UTL_HTTP.BEGIN_REQUEST (url=> v_url, method => 'POST');
  UTL_HTTP.SET_HEADER (r      =>  req,
                       name   =>  'Content-Type',
                       value  =>  'application/x-www-form-urlencoded');
  UTL_HTTP.SET_HEADER (r      =>   req,
                       name   =>   'Content-Length',
                       value  =>   v_param_length);
  UTL_HTTP.WRITE_TEXT (r      =>   req,
                       data   =>   v_param);  resp := UTL_HTTP.GET_RESPONSE(req);
  LOOP
    UTL_HTTP.READ_LINE(resp, value, TRUE);
    DBMS_OUTPUT.PUT_LINE(value);
  END LOOP;
  UTL_HTTP.END_RESPONSE(resp);
EXCEPTION
  WHEN UTL_HTTP.END_OF_BODY THEN
    UTL_HTTP.END_RESPONSE(resp);
END;

	

Send BULK SMS From NodeJS

Generate Token : https://sms.greenweb.com.bd/index.php?ref=gen_token
Method 1:
You will need axios to use it

const axios = require('axios');

const greenwebsms = new URLSearchParams();
greenwebsms.append('token', 'yourtokenhere');
greenwebsms.append('to', '+88017xxxxxxx');
greenwebsms.append('message', 'test sms');
axios.post('http://api.greenweb.com.bd/api.php', greenwebsms).then(response => {
  console.log(response.data);
});
	
Mehtod 2:

var http = require('http');
var querystring = require('querystring');

var postData = querystring.stringify({
    token: 'your token code here',
    to: '+88017xxxxxxxxx',
    message: 'Test sms using API'
});

var options = {
    hostname: 'api.greenweb.com.bd',
    path: '/api.php',
    method: 'POST',
    headers: {
        'Content-Type': 'application/x-www-form-urlencoded',
        'Content-Length': postData.length
    }
};

var req = http.request(options, function (res) {
    
    res.setEncoding('utf8');

    res.on('data', function (chunk) {
        console.log('BODY:', chunk);
    });

    res.on('end', function () {
    });
});

req.on('error', function (e) {
    console.log('Problem with request:', e.message);
});

req.write(postData);
req.end();
	

Send BULK SMS From Java

Generate Token : https://sms.greenweb.com.bd/index.php?ref=gen_token

OkHttpClient client = new OkHttpClient();

RequestBody requestBody = new FormBody.Builder()
        .add("token", "Input your token here")
        .add("to", "+88017xxxxxxx")
        .add("message", "Test sms using API")
        .build();

Request postRequest = new Request.Builder()
        .url("http://api.greenweb.com.bd/api.php")
        .post(requestBody)
        .build();

try {
    Response response = client.newCall(postRequest).execute();
    System.out.println(response.body().string());
} catch (IOException e) {
    e.printStackTrace();
}
	

Send BULK SMS From Python

Generate Token : https://sms.greenweb.com.bd/index.php?ref=gen_token

import requests 
greenweburl = "http://api.greenweb.com.bd/api.php"

# your token code here 
token = "XXXXXXXXXXXXXXXXX"

# sms receivers number here (separated by comma) 
to = '+88017xxxxxxx,+88016xxxxxxxx' 

data = {'token':"yourtokenhere", 
		'to':"+88017xxxxxxx,+88016xxxxxxxx", 
		'message':'test sms'} 
 
responses = requests.post(url = greenweburl, data = data) 

# response 
response = responses.text 
print(response) 

	

API Troubleshooting Video Tutorial