yanti ahmad

yanti ahmad

  • NA
  • 7
  • 0

send sms from pc to phone.....using gateway

Aug 8 2008 2:26 AM

hi guys, i just need some reference of doing sms. in fact i already hv a gateway account which given 10 credit for free when u registered. so they give username, password, and API id to connect to their gateway...but it doesnt work for me. i use c#.net 2.0....below is the connection given....

using System;

using System.Data;

using System.Configuration;

using System.Collections;

using System.Web;

using System.Web.Security;

using System.Web.UI;

using System.Web.UI.WebControls;

 using System.Web.UI.WebControls.WebParts;

using System.Web.UI.HtmlControls;

using System.Net; using System.IO;

using System.Text;

using System.Collections.Specialized;

namespace SMS

{

public partial class SendSMS : System.Web.UI.Page

{

protected System.Web.UI.WebControls.Label lblSuccess;

protected System.Web.UI.WebControls.Button Button1;

protected System.Web.UI.WebControls.TextBox TextBox4;

protected void Page_Load(object sender, EventArgs e) { }

private void SendSingleSMS()

{

WebClient client = new WebClient();

NameValueCollection sendNameValueCollection = NameValueCollection();

string uriString = http://api.clickatell.com/http/sendmsg;

string login = "login";

string passwd = "password";

string type = "textmsg";

string phone = "number";

string content = TextBox4.Text; try { sendNameValueCollection.Add("login", login);

sendNameValueCollection.Add("passwd", passwd);

sendNameValueCollection.Add("type", type);

sendNameValueCollection.Add("phoneno", phone);

sendNameValueCollection.Add("sendtime", time);

sendNameValueCollection.Add("message", content);

byte[] responseArray = client.UploadValues(uriString, "POST", sendNameValueCollection);

lblSuccess.Text = "\nResponse received was " + Encoding.ASCII.GetString(responseArray); NameValueCollection.sendNameValueCollection.Clear();

}

catch (WebException we)

{

lblSuccess.Text = "Network error:" + we.Message + "\nStatus code:" + we.Status;

} catch (UriFormatException ufe) {

 lblSuccess.Text = "URI Format Error: " + ufe.Message;

} }

protected void Button1_Click(object sender, EventArgs e)

{

SendSingleSMS();

} } }

 


Answers (2)