2012-10-31 52 views
-3

我想用C#代碼發送短信。
爲此,我使用'clickatell短信網關'。
任何人都可以幫助我嗎?使用C#發送消息

+2

你試過去找些什麼? http://www.clickatell.com/apis-scripts/scripts/c-scripts/ –

+0

幫助你什麼? –

回答

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); 
+0

我用這個代碼它返回ID:7249d373e3acddffdc2b49cd1345c71c –

+0

什麼是這個ID:? –

+1

請記住,您需要首先使用Clickatell註冊一個帳戶,然後將API ID與用戶憑據一起獲取 – chridam