Click here to Skip to main content
15,892,927 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Hi,
I want to integrate a sms API to my website. But I don't know how to do it??
I want to know the process from 1st step.
Can anyone help me????
Posted
Updated 23-Apr-17 23:44pm

Send SMS Using Or Without SMS Getway in asp.net[^]


try way2sms..:)


C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Net;

namespace SMSAPI
{
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 = "custid=undefined&HiddenAction=instantsms&Action=custfrom450000&login=&pass=&MobNo="+no+"&textArea="+msg;
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");
}

}
}


using fullon sms..:)


http://www.c-sharpcorner.com/Blogs/11790/send-sms-from-Asp-Net-using-way2sms.aspx[^]
 
Share this answer
 
v3
Hi,

As one solution is posted by nirav using way2sms.

Now I describe you the process from 1st step.

Just reach to a sms gateway provider(some companies offer this service with various packages).
And they provide the api integration code(sample code as they need, many times it is a http request.)

Now the difference between way2sms and other paid sms gateway,
vary simple if you paid then there is something extra which not in free. There are various packages, so it depends.
some of are:
1) you cant bulk sms in free using way2sms.
2) sms delivery success ration.
3) Delivery report.
4) A vary important, you cant send promotional sms on DND number's. if you did using free service.Them you will be fined.
5) About DND ,using paid service there are two type of plan
a) message only sent/deliverd to non dnd number(the sms gateway filter itself & generate report also for you.)
secon one :
b) Including DND :- you can send informative sms (pre-approved) or some kind of notice eg: monthly paying alert etc. But in this there are various formalities are depends on condition.

Code sample one of them which I used successfully.
C#
public void newapicall(string mobile, string message)
  {
      string username = "hemant";
      string password = "yourpassword";
      string newsender = "hemant";
      string domian = "smsgatewayurl.com";
      string baseurl = "http://" + domian + "/sendhttp.php?user=" + username + "&password=" + password + "&mobiles=" + mobile + "&message=" + message + "&sender=" + newsender;
      WebClient client = new WebClient();
      Stream data = client.OpenRead(baseurl);
      StreamReader reader = new StreamReader(data);
      string s = reader.ReadToEnd();
      data.Close();
      reader.Close();
  }


Thanks
Hemant Singh Rautela My Blog: Developers Blog[^]
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900