Otp verification in android

otp verification in android and Easy SMS Verification in Android using textlocal sms API
OTP verification in android and Easy SMS Verification in Android using Textlocal SMS API

Textlocal is India’s No. 1 Bulk SMS Platform 

To use API of Textlocal you need to sign up and create an API key and receive 10 free SMS credit.

To create Key Check out: https://www.textlocal.in/

You may like these posts

Follow Below code:

//Set This code into your Button Click Event to send OTP and verify this randomly generated number with the user 


                        try {
                            // Construct data
                            String apiKey = "apikey=" + "Your API KEY";
                            Random random=new Random();
                            randomNumber=random.nextInt(999999);
                            String message = "&message=" + "Verify your account with otp "+randomNumber;
                            String sender = "&sender=" + "Developer";
                            String numbers = "&numbers=" + "919876543210"; // Phone number with country code

                          
                            HttpURLConnection conn = (HttpURLConnection) new URL ("https://api.textlocal.in/send/?").openConnection();
                            String data = apiKey + numbers + message + sender;
                            conn.setDoOutput(true);
                            conn.setRequestMethod("POST");
                            conn.setRequestProperty("Content-Length", Integer.toString(data.length()));
                            conn.getOutputStream().write(data.getBytes("UTF-8"));
                            final BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
                            final StringBuffer stringBuffer = new StringBuffer();
                            String line;
                            while ((line = rd.readLine()) != null) {
                                stringBuffer.append(line);
                            }
                            rd.close();

                            SharedPreferences preferences=getSharedPreferences("checkscreen",MODE_PRIVATE);
                            SharedPreferences.Editor editor=preferences.edit();
                            editor.putString("otpnumber", String.valueOf(randomNumber));
                            editor.apply();
                            Toast.makeText(getApplicationContext(),"OTP SEND "+randomNumber,Toast.LENGTH_LONG).show();
                        } catch (Exception e) {
                            System.out.println("Error SMS "+e);
                            Toast.makeText(getApplicationContext(),"Error to OTP SEND",Toast.LENGTH_LONG).show();
                        }

sms verification api android


1 Comments

  1. Peter Manson
    It's quite helpful. Thanks for the detailed information. I am looking for the best bulk SMS service for the my business to grow.