Loading...
Loading...

if you have any confusion, you can watch the following video:

Loading...

7 COMMENTS

  1. This is my code as directed in the video.
    I’m not getting any errors nor am i receiving an OTP on my phone.
    Please help

    protected void btn_otp_Click(object sender, EventArgs e)
    {
    String result;
    string apiKey = “DrXhf8CYfmQ-NcAXvBPyPySQXYmDwfBlnBNBJPt7dQ”;
    string numbers = tb_phone.Text; // in a comma seperated list
    string send = “generator”;
    string name = uname.Text;
    Random rnd = new Random();
    randnumber = (rnd.Next(100000, 999999)).ToString();
    string message = “Hello”+name+”Your OTP is:”+randnumber;

    String url = “https://api.textlocal.in/send/?apikey=” + apiKey + “&numbers=” + numbers + “&message=” + message + “&sender=” + send;
    //refer to parameters to complete correct url string

    StreamWriter myWriter = null;
    HttpWebRequest objRequest = (HttpWebRequest)WebRequest.Create(url);

    objRequest.Method = “POST”;
    objRequest.ContentLength = Encoding.UTF8.GetByteCount(url);
    objRequest.ContentType = “application/x-www-form-urlencoded”;
    try
    {
    myWriter = new StreamWriter(objRequest.GetRequestStream());
    myWriter.Write(url);
    }
    catch (Exception ez)
    {
    Response.Write(ez.ToString());
    }
    finally
    {
    myWriter.Close();
    }

    HttpWebResponse objResponse = (HttpWebResponse)objRequest.GetResponse();
    using (StreamReader sr = new StreamReader(objResponse.GetResponseStream()))
    {
    result = sr.ReadToEnd();
    // Close and clean up the StreamReader
    sr.Close();
    }
    Response.Write(“sent”);
    }

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.