private void button1_Click_1(object sender, EventArgs e) {
string uid = t_uid.Text.Trim();
string pwd = t_pwd.Text.Trim();
string mob = t_mob.Text.Trim();
string msg = t_msg.Text.Trim();
string backinfo = PostData("http://service.winic.org:8009/sys_port/gateway/index.asp?", "id=" + uid + "&pwd=" + pwd + "&to=" + mob + "&c&time=");
vtag.Text = backinfo;
}
public static string PostData(string purl,string str){
try{
byte[] data = System.Text.Encoding.GetEncoding("GB2312").GetBytes(str);
// 准备请求
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(purl);
//设置超时
req.Timeout = 30000;
req.Method = "Post";
req.C;
req.ContentLength = data.Length;
Stream stream = req.GetRequestStream();
// 发送数据
stream.Write(data, 0, data.Length);
stream.Close();
HttpWebResponse rep = (HttpWebResponse)req.GetResponse();
Stream receiveStream = rep.GetResponseStream();
Encoding encode = System.Text.Encoding.GetEncoding("UTF-8");
// Pipes the stream to a higher level stream reader with the required encoding format.
StreamReader readStream = new StreamReader(receiveStream, encode);
Char[] read = new Char[256];
int count = readStream.Read(read, 0, 256);
StringBuilder sb = new StringBuilder("");
while (count > 0)
{
String readstr = new String(read, 0, count);
sb.Append(readstr);
count = readStream.Read(read, 0, 256);
}
rep.Close();
readStream.Close();
return sb.ToString();
}
catch (Exception ex)
{
return "posterror";
}
}
string backinfo=PostData("http://service.winic.org:8009/sys_port/gateway/index.asp?","id=" + uid + "&pwd=" + pwd + "&to=" + to + "&c&time=");
string uid = "帐号";
string pwd = "密码";
string to = "手机号";
string c;