Important Namespaces Used
--------------------------
using System.Net;
using System.Data;
using System.Data.SqlClient;
using System.Collections.Specialized;
---------------------------
(Send Otp) Button Click Event Coding
--------------------------------------
Panel1.Visible = false;
Panel2.Visible = true;
Random random = new Random();
int value = random.Next(1001, 9999);
string destinationaddr = "91" + TextBox1.Text;
string message = "Your OTP Number is " + value + " ( Sent By : Coding Logic and Syntax )";
//Label3.Text = message;
String message1 = HttpUtility.UrlEncode(message);
using (var wb = new WebClient())
{
byte[] response = wb.UploadValues("https://api.textlocal.in/send/", new NameValueCollection()
{
{"apikey" , "FammnpFW0Ks-gRKkiQvnke2nG940NkDbbl4jUV4elK"},
{"numbers" , destinationaddr},
{"message" , message1},
{"sender" , "TXTLCL"}
});
string result = System.Text.Encoding.UTF8.GetString(response);
Session["otp"] = value;
}
--------------------------------------
( Verify ) Button Click Event Coding
--------------------------------------
if(TextBox2.Text==Session["otp"].ToString())
{
Panel2.Visible = false;
Label3.Text = "Your Mobile Number Has Been Verified Successfully - Thanks";
}
else
{
Label3.Text = "OTP Number is Not Correct : Your Mobile Number not Verified";
Panel2.Visible = true;
}
----------------------------------------
--------------------------
using System.Net;
using System.Data;
using System.Data.SqlClient;
using System.Collections.Specialized;
---------------------------
(Send Otp) Button Click Event Coding
--------------------------------------
Panel1.Visible = false;
Panel2.Visible = true;
Random random = new Random();
int value = random.Next(1001, 9999);
string destinationaddr = "91" + TextBox1.Text;
string message = "Your OTP Number is " + value + " ( Sent By : Coding Logic and Syntax )";
//Label3.Text = message;
String message1 = HttpUtility.UrlEncode(message);
using (var wb = new WebClient())
{
byte[] response = wb.UploadValues("https://api.textlocal.in/send/", new NameValueCollection()
{
{"apikey" , "FammnpFW0Ks-gRKkiQvnke2nG940NkDbbl4jUV4elK"},
{"numbers" , destinationaddr},
{"message" , message1},
{"sender" , "TXTLCL"}
});
string result = System.Text.Encoding.UTF8.GetString(response);
Session["otp"] = value;
}
--------------------------------------
( Verify ) Button Click Event Coding
--------------------------------------
if(TextBox2.Text==Session["otp"].ToString())
{
Panel2.Visible = false;
Label3.Text = "Your Mobile Number Has Been Verified Successfully - Thanks";
}
else
{
Label3.Text = "OTP Number is Not Correct : Your Mobile Number not Verified";
Panel2.Visible = true;
}
----------------------------------------
this is not working .I cannot send MSG
ReplyDeleteAPI key -"uxCstHkdalY-OfYbCOrFXl0F4nqPmGboWDC7sUiOuJ"
I need your help .
below is my code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Net;
using System.Data;
using System.Data.SqlClient;
using System.Collections.Specialized;
namespace OTP_generation
{
public partial class Mobile_Verification : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
Panel1.Visible = false;
Panel2.Visible = true;
try
{
Random random = new Random();
int value = random.Next(1001, 9999);
string destinationaddr = "91" + TextBoxmob.Text;
string message = "Your OTP Number is" + value + "(Sent by Payal Morekar----Testing Testing)";
string message1 = HttpUtility.UrlEncode(message);
using (var wb = new WebClient())
{
byte[] response = wb.UploadValues("https://api.textlocal.in/send/", new NameValueCollection()
{
{"apikey" , "uxCstHkdalY-OfYbCOrFXl0F4nqPmGboWDC7sUiOuJ"},
{"numbers" , destinationaddr},
{"message" , message1},
{"sender" , "TXTLCL"}
});
string result = System.Text.Encoding.UTF8.GetString(response);
Session["otp"] = value;
}
}
catch (Exception es)
{
Response.Write(es.ToString());
}
}
protected void Buttonverotp_Click(object sender, EventArgs e)
{
if (TextBoxotp.Text == Session["otp"].ToString())
{
Panel2.Visible = false;
Response.Write("Your Mobile Number Has Been Verified Successfully - Thanks");
}
else
{
Response.Write("OTP Number is Not Correct : Your Mobile Number not Verified");
Panel2.Visible = true;
}
}
}
}
very useful code.
ReplyDeleteOTP message is not showing the message
ReplyDeleteNot Working Properly
ReplyDeletei Need Your Help
using System;
using System.Collections.Generic;
using System.Net;
using System.Collections.Specialized;
using System.IO;
using System.Text;
using System.Web;
using System.Net;
using System.Data;
using System.Data.SqlClient;
using System.Collections.Specialized;
public partial class User_OTP : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
Panel1.Visible = false;
Panel2.Visible = true;
Random random = new Random();
int value = random.Next(1001, 9999);
string destinationaddr = "91" + TextBox1.Text;
string message = "Your OTP Number is " + value + " ( Sent By : Coding Logic and Syntax )";
//Label3.Text = message;
String message1 = HttpUtility.UrlEncode(message);
using (var wb = new WebClient())
{
byte[] response = wb.UploadValues("https://api.textlocal.in/send/", new NameValueCollection()
{
{"apikey" , "Lqn5n6ovuDM-tfn3l6kNLpHHaMA2X8Usl0brJORqyU"},
{"numbers" , destinationaddr},
{"message" , message1},
{"sender" , "TXTLCL"}
});
string result = System.Text.Encoding.UTF8.GetString(response);
Session["otp"] = value;
}
}
protected void Button2_Click(object sender, EventArgs e)
{
if (TextBox2.Text == Session["otp"].ToString())
{
Panel2.Visible = false;
Response.Write("Your Mobile Number Has Been Verified Successfully - Thanks");
}
else
{
Response.Write("OTP Number is Not Correct : Your Mobile Number not Verified");
Panel2.Visible = true;
}
}
}
Thanks for sharing
ReplyDeleteplz check : OTP SMS delivers instantly
verified mobile number is not receiving OTP
ReplyDeleteThat is really nice to hear. thank you for the update and good luck. Ben Luker Modern Behaviour
ReplyDelete