posts - 66,comments - 41,trackbacks - 0
    项目中的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 阅读(214) 评论(0)  编辑  收藏 所属分类: dotNet

只有注册用户登录后才能发表评论。


网站导航: