Prasenjit  Dey

Prasenjit Dey

  • NA
  • 251
  • 56.6k

Code for send sms is not working

Feb 23 2015 4:45 AM
I have used below code for send sms.
 in aspx
 
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="sms.aspx.cs" Inherits="sms.sms" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>Send Sms</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Label ID="Label1" runat="server" Text="Mobile No"></asp:Label> <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<br />
<asp:Label ID="Label2" runat="server" Text="Message"></asp:Label>
&nbsp;&nbsp;
<asp:TextBox ID="TextBox2" runat="server" TextMode="MultiLine"></asp:TextBox>
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<asp:Button ID="Button1" runat="server" Text="Send Sms"
onclick="Button1_Click" />
</div>
</form>
</body>
</html>
And in .cs page:
 
using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Net;
namespace sms
{
public partial class sms : System.Web.UI.Page
{
string uid;
string password;
string message;
string no;
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
try
{
uid = "9836599564";
password = "8119fc";
message = TextBox2.Text;
no = TextBox1.Text;
send();
TextBox2.Text = "";
TextBox1.Text = "";
}
catch (Exception ex)
{
ex.Message.ToString();
}
}
//This is the code of API for sending message.
public void send()
{
HttpWebRequest myReq = (HttpWebRequest)WebRequest.Create("http://ubaid.tk/sms/sms.aspx?uid=" + uid + "&pwd=" + password + "&msg=" + message + "&phone=" + no + "&provider=fullonsms");
HttpWebResponse myResp = (HttpWebResponse)myReq.GetResponse();
System.IO.StreamReader respStreamReader = new System.IO.StreamReader(myResp.GetResponseStream());
string responseString = respStreamReader.ReadToEnd();
respStreamReader.Close();
myResp.Close();
}
}
}
 
 
 
But after running the above code it shows an error, error is
The remote server returned an error: (403) Forbidden. 
 
 
As far I know, this error shows, if an unauthenticated user tries to enter into the webservice. But I have create a account in fullonsms.com and just put the details in the uid and pwd. I don't know, what is reason behind this error. So please anyone can help me. 

Answers (1)