private void button1_Click(object sender, EventArgs e) { SNSCOMSERVER.SnsComObject sms = new SNSCOMSERVER.SnsComObject(); int ret = sms.Login("203.66.172.133", 8001, "10371", "10371"); if (ret != 0) throw new Exception("error!"); ret = sms.SubmitBig5Message("0988163835","中文測試"); if (ret != 0) throw new Exception("error!"); string smsid = sms.RespMessage; do { System.Threading.Thread.Sleep(1000); ret = sms.QryMessageStatus("0988163835", smsid); } while (ret == 1); if (ret != 0) throw new Exception("error!"); sms.Logout(); }
public int SendSMS(string phoneNo, string body) { //string encodebody = ""; //string urlbase = "http://202.39.48.216/kotsmsapi-1.php?username=fortech&password=123456&dstaddr={0}&smbody={1}&dlvtime=0"; //byte[] codebig5 =stringToBig5Bytes(body); //encodebody = System.Web.HttpUtility.UrlEncode(codebig5); //string uristr = string.Format(urlbase, phoneNo, encodebody); //System.Net.WebRequest web = System.Net.HttpWebRequest.Create(new Uri(uristr // , UriKind.Absolute) // ); //System.IO.Stream stream = web.GetResponse().GetResponseStream(); //System.IO.StreamReader rd = new System.IO.StreamReader(stream); //string res = rd.ReadToEnd(); SNSCOMSERVER.SnsComObject sms = new SNSCOMSERVER.SnsComObject(); int ret = sms.Login("203.66.172.133", 8001, "10371", "10371"); if (ret != 0) { return 1; } string mesg =body; string[] messages = new string[mesg.Length % 70 == 0 ? mesg.Length / 70 : mesg.Length / 70 + 1]; for (int i = 0; i < messages.Length; i++) { if (i == messages.Length - 1) messages[i] = mesg.Substring(i * 70); else messages[i] = mesg.Substring(i * 70, 70); } for (int i = 0; i < messages.Length; i++) ret = sms.SubmitBig5Message(phoneNo, messages[i]); // ret = sms.SubmitBig5Message(phoneNo, body); if (ret != 0) { return 1; //throw new Exception("error!"); } string smsid = sms.RespMessage; //do //{ // System.Threading.Thread.Sleep(1000); // ret = sms.QryMessageStatus(phoneNo, smsid); //} //while (ret == 1 ); //if (ret != 0) // throw new Exception("error!"); sms.Logout(); return ret; }
private void button1_Click(object sender, EventArgs e) { SNSCOMSERVER.SnsComObject sms = new SNSCOMSERVER.SnsComObject(); int ret = sms.Login("203.66.172.133", 8001, "10371", "10371"); if (ret != 0) { throw new Exception("error!"); // return 1; } string mesg=this.textBox1.Text; string[] messages = new string[mesg.Length % 70 == 0 ? mesg.Length / 70 : mesg.Length / 70 + 1]; for (int i = 0; i < messages.Length; i ++) { if (i == messages.Length - 1) messages[i] = mesg.Substring(i * 70); else messages[i] = mesg.Substring(i * 70, 70); } for (int i = 0; i < messages.Length;i++ ) ret = sms.SubmitBig5Message("0988163835", messages[i]); if (ret != 0) { // return 1; throw new Exception("error!"); } string smsid = sms.RespMessage; //do //{ // System.Threading.Thread.Sleep(1000); // ret = sms.QryMessageStatus(phoneNo, smsid); //} //while (ret == 1 ); //if (ret != 0) // throw new Exception("error!"); sms.Logout(); }