一種是http請求的方式,另外一種就是提供WebService接口供調用的。web
#region sms.webchinese.cn 發送短信
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- public int SendMSG(string mobilenumber, string message)
- {
-
- string url = string.Format("http://sms.webchinese.cn/web_api/?Uid=帳號&Key=接口密鑰&smsMob={0}&smsText={1}", mobilenumber, message);
- string strRet = null;
- url = HttpUtility.UrlEncode(url);
- if (url == null || url.Trim().ToString() == "")
- {
- return 0;
- }
- try
- {
- HttpWebRequest hr = (HttpWebRequest)WebRequest.Create(url);
- hr.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)";
- hr.Method = "GET";
- hr.Timeout = 30 * 60 * 1000;
- WebResponse hs = hr.GetResponse();
- Stream sr = hs.GetResponseStream();
- StreamReader ser = new StreamReader(sr, Encoding.Default);
- strRet = ser.ReadToEnd();
- }
- catch (Exception)
- {
- strRet = null;
- }
- if (strRet == null || strRet == "") return 0;
- return Convert.ToInt32(strRet);
- }
- #endregion
-
- #region www.56dxw.com 發送短信
-
-
- private MobileMessage_56.WebServiceInterfaceSoapClient _ws_56 = null;
-
-
-
- public MobileMessage_56.WebServiceInterfaceSoapClient ws_56
- {
- get
- {
- if (_ws_56 == null) _ws_56 = new MobileMessage_56.WebServiceInterfaceSoapClient();
- return _ws_56;
- }
- }
- private string username_56 = "test";
- private string password_56 = "test";
- private string cid_56 = "";
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- public int SendMSG_56(string mobilenumber, string message)
- {
- string sendtime = "";
- string smsnumber = "";
- return ws_56.SendNote(mobilenumber, message, username_56, password_56, cid_56, sendtime, smsnumber);
- }
-
-
-
-
-
-
-
-
- public int ReturnUserFullMoney_56()
- {
- return ws_56.ReturnUserFullMoney(username_56, password_56, cid_56);
- }
-
-
-
-
-
-
-
-
-
-
- public int EditUserPwd(string oldpwd,string newpwd)
- {
- return ws_56.EditUserPwd(username_56, oldpwd, newpwd, cid_56);
- }
-
- #endregion