send-sms-using-way2sms-android thump

Send SMS Using SMS Gateway from Android

In Android, you can use SmsManager API or devices Built-in application to send SMS’s. Therefore in this tutorial, we shows how to send SMS message using SMS Gateway from android. However Some times it’s important to inform user about changes made to there account by email or sms. Such as verification codes,conformations etc, please let me present some interesting facts in this topic.

At this point about 5.1 billion out of the 6.8 billion people on Earth own a mobile phone – that’s a huge.

There are twice as many active SMS users in the world than active users of email.

On average, it takes 9 minutes for someone to respond to an SMS (by comparison, the response time in case of e-mail is 90 minutes).

Around 98 per cent of all messages are opened, but only 20 per cent of emails are looked at.



Of course first is the android part, it transmit address of the recipient and message to be send. In order to transmit network data we are  using volley. And also the response is received by volley network library. As a matter of fact internet permission is required for this project.


In fact way2sms don’t provide an official api for users. Still there are several api’s available unofficially. As a result of googling found a suitable api. Then modified it to work with android. However you can use wamp or any other free hosting providers as server. In the same way api working and it’s integration is explained below.


Accordingly there is a lot of free Sms sending web portals available on the internet. Therefore people use them to send bulk and nonbulk Short messages without any charge. Still Way2Sms is one of the No.1 SMS Portal on the World Wide Web almost 1 million users were registered with them and send millions of message per day. Hence you are going to learn about the Way2Sms Php API Script Integration in an android app in this article.

How Way2Sms API  Script Works:

Consequently by integrating the Way2Sms Php API Script in your app, Your can send  SMS Directly through your app. You are never redirected to Way2Sms official site for login or another purpose. Because every action will take place through your server itself. You can also modify the script design like yours . Because the code was developed using PHP and it was too simple.

How to Integrate Way2Sms PHP API Script:

In fact it’s very easy to integrate the PHP API script on your app or website. In order to do this, you must have a Php Enabled Server (Cpanel). If you don’t have a PHP Supported Server, then create a free A/c on any of the site that listed on the linked page: Link Here


After creating an A/c or log in to your Existing Cpanel A/c, Do the following steps and procedure to integrate the  API script on your website. Or you can use wamp instead.

Above all first Download the script from here: Download,

Then Go to File-Browser of your Cpanel A/c & Create a “New Folder” name “androidsms”.

Afterward Upload the “12sms.rar” Downloaded the file to the “androidsms”.

Next Extract the “12sms.rar” File.

Run like: “”.

You are Done.


Accordingly a SMS-Gateway allows a computer to send or receive Short Message Service transmissions to or from a telecommunications network. Most messages are eventually routed into the mobile phone networks. In fact it’s able to send the messages coming from your Android application through HTTP to the SMSC (Short Message Service Center) of the Mobile Service Provider via SMPP IP SMS connection or a GSM modem. However the SMSC is a network element in the mobile telephone network that stores, forwards, converts and delivers SMS messages. Still to be able to send messages using HTTP, you will need an SMS Gateway that has a built-in webserver. In conclusion it allows you to send text messages from your application by calling an URL (HTTP Get) or using the HTTP Post method.



In addition below is the modified php script for sending message. It also require other script’s from the rar file.


$ckfile = tempnam ("/tmp", "CURLCOOKIE");
// * Reciving Username of Way2sms A/c from Html form //
// * Reciving Password of Way2sms A/c from Html form //
// * To whome the message send to 
// * Message to be sended //

$jsonData      = array();
$jsonTempData  = array();

{ $to=$uid; }
{ $msg=rword(5).rword(5).rword(5).rword(5).rword(5); }
if($uid && $pwd)


$ch = curl_init();

if(stristr($lhtml,'Location: '.$ser.'vem.action') || stristr($lhtml,'Location: '.$ser.'MainView.action') || stristr($lhtml,'Location: '.$ser.'ebrdg.action'))
    goto end;
goto bal;
    goto end;
{goto end;

$post="ssaction=ss&Token=".$id."&mobile=".$to."&message=".$msg."&Send=Send Sms&msgLen=".strlen($msg);
// * Message Sended Sucessfull Message//
    $jsonTempData['sms']    ="Message send";
}   else
// * Login Faild or SMS Send Error Message 1//
    $jsonTempData['sms']   ="Error message 1";

$outputArr['check'] = $jsonData;
// Encode Array To JSON Data
print_r( json_encode($outputArr));


Class file contain the sending of information  number and message.

public class MainActivity extends AppCompatActivity {
private EditText editTextTo,editTextMessage;
    RelativeLayout activity_main;

    private RequestQueue requestQueue;

    protected void onCreate(Bundle savedInstanceState) {
        requestQueue = Volley.newRequestQueue(this);

    public void OnClickButton(View view){
        InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
        imm.hideSoftInputFromWindow(view.getWindowToken(), 0);

            Snack("Number is empty");
        }else if(editTextTo.getText().length()!=10){
            Snack("Check the number");
        }else if(editTextMessage.getText().toString().isEmpty()){
            Snack("Message is empty");

    public void Snack(String message){
        Snackbar.make(activity_main, message, Snackbar.LENGTH_LONG).setAction("Action", null).show();

    public void SendSms(final String to, final String message) {

        StringRequest menuRequest = new StringRequest(Request.Method.POST,"",
                new Response.Listener<String>() {
                    public void onResponse(String response) {
                        try {
                            JSONArray jsonResponse = new JSONObject(response).getJSONArray("check");

                            int i = jsonResponse.length();
                            for(int j=0;j<i;j++){
                                JSONObject jsonChildNode = jsonResponse.getJSONObject(j);


                        } catch (JSONException e) {
                            Snack("Json " + e.getMessage());
                new Response.ErrorListener() {
                    public void onErrorResponse(VolleyError error) {
                        Snack("Volley " + error.getMessage());
        ) {
            protected Map<String, String> getParams() {
                Map<String, String> params = new HashMap<>();
                return params;



Incidentally here is the full code for android: Download.

16 thoughts on “Send SMS Using SMS Gateway from Android”

      1. sir, could you please help me ..! i have uploaded files on the server and error is occuring which says can’t convert jsonobject to jsonarray..please help

        1. Check what’s actually receiving,by printing the json array.then only you can determine where the problem is.

  1. Sir my app is crashing every time i try to send msg and the error is an “NULLPOINTER EXCEPTION” from this line

    34 StringRequest menuRequest = new StringRequest(Request.Method.POST,””,

  2. Sir,
    I download and put files on D:\xampp5.6.15\htdocs\sendsms. it have 10 files (curl,foot,func,head,index,LICENSE,,readme,sms,style).

  3. Sir,
    I also tried with http://localhost/sendsms/. It ask login mobilenumber i enter like that 9876543210 password : pwd1875 receipt: 9785641023 message: msg from logicchip it show the error ‘check your username and password Inorder to Send SMS’ and also on top it show user: 9876543210

        1. There is no official API for way2sms, it was an workaround method.May be they somehow manage to block that.I will notify you as soon as a solution is found.

Leave a Reply Cancel reply

Exit mobile version