Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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;
- using System.Text;
- public partial class OTP : System.Web.UI.Page
- {
- protected void Page_Load(object sender, EventArgs e)
- {
- Panel2.Visible = false;
- }
- 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 destinaddr = "65" + txtMobileNo.Text;
- string message = "Your OTP Number is " + value + " ( Sent By : Unknown )";
- sendSMS(destinaddr, value.ToString());
- }
- public string sendSMS(string usernumber, string OTPCode)
- {
- String message = HttpUtility.UrlEncode("This is your OTP : " + OTPCode + ". This will expire in 30 seconds.");
- using (var wb = new WebClient())
- {
- byte[] response = wb.UploadValues("https://api.txtlocal.com/send/", new NameValueCollection()
- {
- {"apikey" , "iM91uB/r99c-76KWeOLoMqbH2hRCwqgkdUsGeK0fo2"},
- {"numbers" , usernumber},
- {"message" , message},
- {"sender" , "OTP"}
- });
- string result = Encoding.UTF8.GetString(response);
- return result;
- }
- }
- protected void Button2_Click(object sender, EventArgs e)
- {
- string OTP = txtOTP.Text;
- if(OTP == txtOTP.Text)
- {
- Label1.Text = "Verified";
- }
- else
- {
- Label1.Text = "Incorrect OTP";
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement