SOURCE CODE : Download the Csharp Api from HERE
From this api you can send sms from your website. As per you requirements. Using this api is simple and hence i do not think i should mention a tutorial on that ..... .
Will Keep posting , regards.....
Here is the Way 2 Sms C sharp Api :
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Net;
namespace dotnetsnippetssmsapi
{
class SmsSender
{
void send(string uid, string pwd, string no, string msg)
{
String content = "username="+uid+"&password="+pwd;
try
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://wwwa.way2sms.com/auth.cl");
request.KeepAlive = false;
byte[] byteArray = Encoding.UTF8.GetBytes(content);
CookieContainer cookies = new CookieContainer();
request.CookieContainer = cookies;
request.UserAgent = "Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.0.5) Gecko/2008120122 Firefox/3.0.5";
request.ContentLength = byteArray.Length;
request.ContentType = "application/x-www-form-urlencoded";
request.Accept = "*/*";
request.Referer = "http://wwwg.way2sms.com//entry.jsp";
request.Method = "POST";
Stream dataStream = request.GetRequestStream();
dataStream.Write(byteArray, 0, byteArray.Length);
dataStream.Close();
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
foreach (Cookie cook in response.Cookies)
{
cookies.Add(cook);
}
Stream stream = response.GetResponseStream();
StreamReader reader = new StreamReader(stream);
string serverData = reader.ReadToEnd();
reader.Close();
content="HiddenAction=instantsms&login=&pass=&custid=&Action=custfrom1000000&sponserid=undefined&MobNo="
+ ToMobile + "&textArea=" + mesg
request = (HttpWebRequest)WebRequest.Create("http://wwwa.way2sms.com/FirstServletsms?custid=");
byteArray = Encoding.UTF8.GetBytes(content);
request.UserAgent = "Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.0.5) Gecko/2008120122 Firefox/3.0.5";
request.ContentLength = byteArray.Length;
request.ContentType = "application/x-www-form-urlencoded";
request.Accept = "*/*";
request.CookieContainer = cookies;
request.Method = "POST";
dataStream = request.GetRequestStream();
dataStream.Write(byteArray, 0, byteArray.Length);
dataStream.Close();
response = (HttpWebResponse)request.GetResponse();
stream = response.GetResponseStream();
reader = new StreamReader(stream);
serverData = reader.ReadToEnd();
reader.Close();
request = (HttpWebRequest)WebRequest.Create("http://wwwa.way2sms.com/jsp/logout.jsp");
byteArray = Encoding.UTF8.GetBytes(content);
request.UserAgent = "Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.0.5) Gecko/2008120122 Firefox/3.0.5";
request.ContentLength = byteArray.Length;
request.ContentType = "application/x-www-form-urlencoded";
request.Accept = "*/*";
request.CookieContainer = cookies;
request.Method = "POST";
dataStream = request.GetRequestStream();
dataStream.Write(byteArray, 0, byteArray.Length);
dataStream.Close();
response = (HttpWebResponse)request.GetResponse();
stream = response.GetResponseStream();
reader = new StreamReader(stream);
serverData = reader.ReadToEnd();
reader.Close();
}
catch (ArgumentException e)
{
Console.WriteLine("arg exception");
Console.Read();
}
catch (WebException e)
{
Console.WriteLine("web exception");
Console.Read();
}
catch (Exception e)
{
Console.WriteLine("exception");
Console.Read();
}
}
static void Main(string[] args)
{
SmsSender sms = new SmsSender();
sms.send("username", "password", "phno_recipient", "message");
}
}
}
/*Downloaded from dotnetsnippets.co.cc*/
11 comments:
plz give the implementation details
go Here
Hi Vaibhav
I tried using the above code,but i am not able to send the SMS.Though i am not getting any exception and code is executing successfully.But SMSs are not going to the numbers which i am trying to send.
Pls can u give me the updated code.
Thanks
namit
I have Just Updated the API to my current api which i am using in the demo...The demo is given over here . If the demo is working for you then this API will also work.
Hi
API is working fine.But as it is my college project,So it will be great if you can provide me the code.
Thanks in advance
Ps:- I am a novice to c#.
I have tried the above code,it is not working at my end
Ps:-I am a novice to c#
I have made another tutorial for newbies http://www.code-globe.co.cc/2011/01/way-2-sms-api-demo-source-code.html
Hi
Thnx for the tutorial.But it has not solved my problem.As i am student and doing a college project,so i need the entire source code and not only the API implementation.I have used the above code and even change the http://wwwa.way2sms.com/jsp/logout.jsp to its current address http://site7.way2sms.com/jsp/logout.jsp and subsequently all the other references.I have compiled the code and it is executing without any error, but still i am not able to send the SMS to the numbers.
It will be kind on your part if you can help me by providing the latest source code.
Thnx in advance.
Above code is not working.
As i have mentioned in my other post that the api needs to be regularly updated , u need to experiment with the code from time to time this was the api properly working when i ahd posted the post i will be updating my API as soon as my computer starts working between with my exams on it was tough to manage this blog , sorry to all of u but will be posting great articles soon .
SMS marketing is a well-known advertising tactic that will help you to send SMS in bulk. But send an individual message to each person is a hectic task. MsgClub has discovered a unique SMS API C# that one can integrate with the website, software, and application.
Post a Comment