Forums » .NET » ASP.NET »

How to create account in way2sms to send sms


Posted Date: 30 Jan 2012      Posted By:: vijayalakshmi     Member Level: Silver    Member Rank: 324     Points: 1   Responses: 4



I need to send sms by using way 2sms account,how to create account in it



Responses

#654404    Author: Anil Kumar Pandey      Member Level: Diamond      Member Rank: 1     Date: 30/Jan/2012   Rating: 2 out of 52 out of 5     Points: 4

Here is the sample code to send SMS using the WAY 2 SMS account.


public void sendSMS(string uid, string password, string message, string no)
{
HttpWebRequest myReq =
(HttpWebRequest)WebRequest.Create("http://ubaid.tk/sms/sms.aspx?uid=" + uid + "&pwd=" + password +
"&msg=" + message + "&phone=" + no + "&provider=way2sms");

HttpWebResponse myResp = (HttpWebResponse)myReq.GetResponse();
System.IO.StreamReader respStreamReader = new System.IO.StreamReader(myResp.GetResponseStream());
string responseString = respStreamReader.ReadToEnd();
respStreamReader.Close();
myResp.Close();
}




protected void Button1_Click(object sender, EventArgs e)
{
sendSMS("yourmobileno","yourpassword", TextBox2.Text, TextBox1.Text);
}



Thanks & Regards
Anil Kumar Pandey
Microsoft MVP, DNS MVM


 
#654412    Author: vijayalakshmi      Member Level: Silver      Member Rank: 324     Date: 30/Jan/2012   Rating: 2 out of 52 out of 5     Points: 1

Hi
I am Calling the method as follows

sendSMS("8374187075", "sailaja", txtmessage.Text, pno);
But getting error as invalid arguments where pno contains the phone number,txtmessage is the message to be sent.


 
#654420    Author: vijayalakshmi      Member Level: Silver      Member Rank: 324     Date: 30/Jan/2012   Rating: 2 out of 52 out of 5     Points: 1

Hi
i want to send sms in school project,i need to append the name of school as CHS at end of message How to do this





 
#654575    Author: Govind      Member Level: Silver      Member Rank: 700     Date: 31/Jan/2012   Rating: 2 out of 52 out of 5     Points: 4

Hello,

here is code for you.

First of all declare following variable in your code file

string mbno, mseg, ckuser, ckpass;
private HttpWebRequest req;
private CookieContainer cookieCntr;
private string strNewValue;
public static string responseee;
private HttpWebResponse response;

Now write following code on your page load event

protected void Page_Load(object sender, EventArgs e)
{
ckuser = "Yourusername";
ckpass = "YourPassword";

try
{
this.req = (HttpWebRequest)WebRequest.Create("http://wwwd.way2sms.com/auth.cl");

this.req.CookieContainer = new CookieContainer();
this.req.AllowAutoRedirect = false;
this.req.Method = "POST";
this.req.ContentType = "application/x-www-form-urlencoded";
this.strNewValue = "username=" + ckuser + "&password=" + ckpass;
this.req.ContentLength = this.strNewValue.Length;
StreamWriter writer = new StreamWriter(this.req.GetRequestStream(), Encoding.ASCII);
writer.Write(this.strNewValue);
writer.Close();
this.response = (HttpWebResponse)this.req.GetResponse();
this.cookieCntr = this.req.CookieContainer;
this.response.Close();
this.req = (HttpWebRequest)WebRequest.Create("http://wwwd.way2sms.com//jsp/InstantSMS.jsp?val=0");
this.req.CookieContainer = this.cookieCntr;
this.req.Method = "GET";
this.response = (HttpWebResponse)this.req.GetResponse();
responseee = new StreamReader(this.response.GetResponseStream()).ReadToEnd();
int index = Regex.Match(responseee, "custf").Index;
responseee = responseee.Substring(index, 0x12);
responseee = responseee.Replace("\"", "").Replace(">", "").Trim();
this.response.Close();

pnlsend.Visible = true;
lblErrormsg.Text = "connected";
}
catch (Exception)
{
lblErrormsg.Text = "Error connecting to the server...";
}
}

Above code will connect your account to way2sms please chnage highlighted code with your username password

Now write following on btnMessageSend_Click event.

protected void btnSend_Click(object sender, EventArgs e)
{
mbno = txtTo.Text;//To mobile number
mseg = txtMessage.Text;//Message

if ((mbno != "") && (mseg != ""))
{
try
{
this.req = (HttpWebRequest)WebRequest.Create("http://wwwd.way2sms.com//FirstServletsms?custid=");
this.req.AllowAutoRedirect = false;
this.req.CookieContainer = this.cookieCntr;
this.req.Method = "POST";
this.req.ContentType = "application/x-www-form-urlencoded";
this.strNewValue = "custid=undefined&HiddenAction=instantsms&Action=" + responseee + "&login=&pass=&MobNo=" + this.mbno + "&textArea=" + this.mseg;

string msg = this.mseg;
string mbeno = this.mbno;

this.req.ContentLength = this.strNewValue.Length;
StreamWriter writer = new StreamWriter(this.req.GetRequestStream(), Encoding.ASCII);
writer.Write(this.strNewValue);
writer.Close();
this.response = (HttpWebResponse)this.req.GetResponse();

this.response.Close();
lblErrormsg.Text = "Message Sent..... " + mbeno + ": " + msg;
}
catch (Exception)
{
lblErrormsg.Text="Error Sending msg....check your connection...";
}
}
else
{
lblErrormsg.Text = "Mob no or msg missing";
}
}

Thanks & Regards
Govind Jangir


 
Post Reply

 This thread is locked for new responses. Please post your comments and questions as a separate thread.
If required, refer to the URL of this page in your new post.



Next : Asp.net certification Dumps
Previous : Please help me, i am having a problem : Ban a IP address
Return to Discussion Forum
Post New Message
Category: ASP.NET

Related Messages

Subscribe to Subscribers
Active Members
TodayLast 7 Daysmore...

Awards & Gifts
Talk to Webmaster Tony John

Online Members

Priya jain
More...
Copyright © SpiderWorks Technologies Pvt Ltd., Kochi, India