在程序中与外部网站进行交互访问实例
通过HTTP80端口发送手机短信
由于联系的手机厂商为只能提供从HTTP80端口发送信息,故对此编写了以下代码:
string MobileNo = "";//手机号码
string MsgContent = "";//短信内容
WebProxy myproxy = new WebProxy("172.22.252.66:80", true);
myproxy.Credentials = new NetworkCredential("Yong-Chao_Lu", "!lyc760408", "maintek");
string[] MobileCode = MobileNo.Split(';');
foreach (string curCode in MobileCode)
{
if (curCode.Trim().Length > 8)//号码长度判断
{
WebRequest WReq;
WebResponse WResp;
string url = "http://221.224.134.226/guanshuo/insert.asp?tel_no=" + curCode + "&content=" + MsgContent + "&user_name=客户名称&user_IP=客户标识";
WReq = WebRequest.Create(url);
WReq.Proxy = myproxy;
WResp = WReq.GetResponse();
}
}