-3

我想使用 C# 代码发送短信。
为此,我正在使用“clickatell 短信网关”。
有人能帮我解决这个问题吗?

4

1 回答 1

2

从他们的网站,C# Scripts

using System.Net;
using System.IO;
WebClient client = new WebClient ();
// Add a user agent header in case the requested URI contains a 
query.
client.Headers.Add ("user-agent", "Mozilla/4.0
 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR
1.0.3705;)");
client.QueryString.Add("user", "xxxx");
client.QueryString.Add("password", "xxxx");
client.QueryString.Add("api_id", "xxxx");
client.QueryString.Add("to", "xxxx");
client.QueryString.Add("text", "This is an example message");
string baseurl ="http://api.clickatell.com/http/sendmsg";
Stream data = client.OpenRead(baseurl);
StreamReader reader = new StreamReader (data);
string s = reader.ReadToEnd ();
data.Close ();
reader.Close ();
return (s);
于 2012-10-31T09:44:15.133 回答