Gulpreet Arora

Gulpreet Arora

  • NA
  • 1
  • 1.1k

how to send sms from asp .net with smsgatewayhub

Apr 6 2016 3:12 AM
Hello Team,
 
this is our Code. ]
 
   
using System
using System
using System.IO
using System.Net
u
sing System.Text
using System.Web
string s
APIKey
= “
APIKEY
”;
string sNumber = Session["Mobile"].ToString();
string sMessage = “Test SMS From Our Company”;
string sSenderID = “WEBSMS”;
string sURL = “
http://login.smsgatewayhub.com/api/mt/SendSMS?
APIKey
=” + s
APIKEY
+ “&to=” + sNumber
+ “&sid=” + sSenderID + “&msg=” + sMessage + “&fl=0?;
string sResponse = GetResponse(sURL);
Response.Write(sResponse);
public static string GetResponse(string sURL)
{
HttpWebRequest request =
(HttpWebRequest)WebRequest
.Create(sURL);
request.MaximumAutomaticRedirections = 4;
request.Credentials = CredentialCache.DefaultCredentials;
try
{
HttpWebResponse response = (HttpWebResponse)request
.GetResponse();
Stream receiveStream = response.GetResp
onseStream(
);
StreamReader readStream = new StreamReader(receiveStream, Encoding.UTF8);
string sResponse = readStream.ReadToEnd();
response.Close();
readStream.Close();
return sResponse;
}
catch
{
return “”;
}
 
}

Answers (4)