項目中的OTA Server中的一個功能。具體使用請看https://www.clickatell.com/developers/api_http.php
代碼如下:
1 protected void SendSMS()
2 {
3
4 string api_id = "xxxxxx";//api_id請查閱clicktell網站幫助
5 string user = "xxxxxx";
6 string password = "xxxxx";
7 //string mobile = "xxxxxx";
8 string mobile = txtMobile.Text;//一個輸入手機號的文本框
9
10 string appUri = getAppUri();//發送給手機的App鏈接,出于保密,此處假設了getAppUri()方法
11
12 StringBuilder smsParams = new StringBuilder();
13 smsParams.Append("api_id=" + api_id);
14 smsParams.Append("&user=" + user);
15 smsParams.Append("&password=" + password);
16 smsParams.Append("&to=" + mobile);
17 smsParams.Append("&text=" + appUri);
18
19
20
21 Uri smsuri = new Uri(string.Format("http://api.clickatell.com/http/sendmsg?{0}", smsParams));
22
23 HttpWebRequest request = (HttpWebRequest)WebRequest.Create(smsuri);
24
25 request.AllowAutoRedirect = false;
26
27 request.Method = "GET";
28
29
30 HttpWebResponse response = (HttpWebResponse)request.GetResponse();
31
32 }
33
34
這個方法不僅適用于clicktell公司的服務,其它的一些SMS服務提供商,用C#調用方法也差不多,僅供大家參考,呵呵
MSN:
posted on 2009-07-16 21:52
kylixlu 閱讀(223)
評論(0) 編輯 收藏 所屬分類:
dotNet