IsraelRank #1,454 · 1.1K pointsPosted Dec 17, 2016, 4:55 AM EST
0
Thank you Sir Dr Ajay
I am using this service and I do send SMS through my Windows Application as you can see below some example code. But I am still looking for a long time how can I send and receive SMS from and send to my web server. Can I have a good help on it from some practice code please. I will appreciate.
C#
try
{
WebClient client1 = new WebClient();
string to, msg;
to = txtSMS.Text;
msg = txtReceive.Text;
string baseurl = "http://api.clickatell.com/http/sendmsg?user=xxx&password=xxx&api_id=xxx&to='" + to + "'&text='" + msg + "'";
client1.OpenRead(baseurl);
MessageBox.Show("SMS sent...");
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
Thank you in advance.
0
Dr.Ajay KashyapRank #3,451 · 416 pointsPosted Dec 18, 2016, 7:33 AM EST
0
I Don't understand what exactly You Want say ... You want to receive Sms In Your Browser and You also Want to send sms Using browser right ..
See How I Use for One Time Password:-
Java
String result;
stringuserName="xxxxxxxx";
stringhash="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
stringnumbers="91" + sud.ContactNo; // in a comma seperated liststringmessage="You Are Registered Successfully!";
stringsender="Kashyap And Company";
Stringurl="http://api.textlocal.in/send/?username=" + userName + "&hash=" + hash + "&numbers=" + numbers + "&message=" + message + "&sender=" + sender;
//refer to parameters to complete correct url stringStreamWritermyWriter=null;
HttpWebRequestobjRequest= (HttpWebRequest)WebRequest.Create(url);
objRequest.Method = "POST";
objRequest.ContentLength = Encoding.UTF8.GetByteCount(url);
objRequest.ContentType = "application/x-www-form-urlencoded";
try
{
myWriter = newStreamWriter(objRequest.GetRequestStream());
myWriter.Write(url);
}
catch (Exception e)
{
returnnull;
}
finally
{
myWriter.Close();
}
HttpWebResponseobjResponse= (HttpWebResponse)objRequest.GetResponse();
using (StreamReadersr=newStreamReader(objResponse.GetResponseStream()))
{
result = sr.ReadToEnd();
// Close and clean up the StreamReader
sr.Close();
}
1) A local or parameter name 'sender' cannot be decalred in this scope because that name is used in an enclosing local scope to define a local or parameter
2) The name 'Encoding' does not exist in the current context
3) Represents errors that occur during application execution
4) Since 'frmSMS.btnSMS_Click(objrct, EventArgs)' return void, a return keyword must not be followes by an object expression
0
Dr.Ajay KashyapRank #3,451 · 416 pointsPosted Dec 25, 2016, 6:27 PM EST
0
I dont Know Why Are U getting Error .....I think U Just Try......
1).... string numbers = "91" + sud.ContactNo;
In Which Number U Want To send Msg spacify 91..
2).... try Following namespace
PowerShell
using System.Web.Mvc;
using System.Web.Security;
using System.Text;
using System.Net.Mime;
using Microsoft.Ajax.Utilities;
Dr.Ajay KashyapRank #3,451 · 416 pointsPosted Dec 17, 2016, 2:44 AM EST
IsraelRank #1,454 · 1.1K pointsPosted Dec 17, 2016, 4:55 AM EST
try { WebClient client1 = new WebClient(); string to, msg; to = txtSMS.Text; msg = txtReceive.Text; string baseurl = "http://api.clickatell.com/http/sendmsg?user=xxx&password=xxx&api_id=xxx&to='" + to + "'&text='" + msg + "'"; client1.OpenRead(baseurl); MessageBox.Show("SMS sent..."); } catch (Exception ex) { MessageBox.Show(ex.Message); }Dr.Ajay KashyapRank #3,451 · 416 pointsPosted Dec 18, 2016, 7:33 AM EST
String result; string userName = "xxxxxxxx"; string hash = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; string numbers = "91" + sud.ContactNo; // in a comma seperated list string message = "You Are Registered Successfully!"; string sender = "Kashyap And Company"; String url = "http://api.textlocal.in/send/?username=" + userName + "&hash=" + hash + "&numbers=" + numbers + "&message=" + message + "&sender=" + sender; //refer to parameters to complete correct url string StreamWriter myWriter = null; HttpWebRequest objRequest = (HttpWebRequest)WebRequest.Create(url); objRequest.Method = "POST"; objRequest.ContentLength = Encoding.UTF8.GetByteCount(url); objRequest.ContentType = "application/x-www-form-urlencoded"; try { myWriter = new StreamWriter(objRequest.GetRequestStream()); myWriter.Write(url); } catch (Exception e) { return null; } finally { myWriter.Close(); } HttpWebResponse objResponse = (HttpWebResponse)objRequest.GetResponse(); using (StreamReader sr = new StreamReader(objResponse.GetResponseStream())) { result = sr.ReadToEnd(); // Close and clean up the StreamReader sr.Close(); }IsraelRank #1,454 · 1.1K pointsPosted Dec 24, 2016, 9:57 AM EST
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Net; using System.IO; public partial class frmSMS : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void btnSMS_Click(object sender, EventArgs e) { String result; string userName = txtUserName.Text; string hash = txtHash.Text; string numbers = txtNumbers.Text; // in a comma seperated list string message = txtMessage.Text; string sender = "Kashyap And Company"; String url = "http://api.clickatell.com/http/sendmsg?userName=Me&password=123&api_id=1234&to=" + userName + "&hash=" + hash + "&numbers=" + numbers + "&message=" + message + "&sender=" + sender; //refer to parameters to complete correct url string StreamWriter myWriter = null; HttpWebRequest objRequest = (HttpWebRequest)WebRequest.Create(url); objRequest.Method = "POST"; objRequest.ContentLength = Encoding.UTF8.GetByteCount(url); objRequest.ContentType = "application/x-www-form-urlencoded"; try { myWriter = new StreamWriter(objRequest.GetRequestStream()); myWriter.Write(url); } catch (Exception e) { return null; } finally { myWriter.Close(); } HttpWebResponse objResponse = (HttpWebResponse)objRequest.GetResponse(); using (StreamReader sr = new StreamReader(objResponse.GetResponseStream())) { result = sr.ReadToEnd(); // Close and clean up the StreamReader sr.Close(); } } }Dr.Ajay KashyapRank #3,451 · 416 pointsPosted Dec 25, 2016, 6:27 PM EST
using System.Web.Mvc; using System.Web.Security; using System.Text; using System.Net.Mime; using Microsoft.Ajax.Utilities;1 short reply
IsraelRank #1,454 · 1.1K pointsPosted Dec 18, 2016, 6:27 AM EST