标签:div ati creat control res hold fresh www 内容
本人亲自试用可以用,现在的手机短信服务商很多,可以自己去找个,
我这个用的是齐鲁商务通接口调用dotNet样例.zip的接口,也是用的不错的,如果有需要的话我可以给提供
本例子用的就是他们提供的接口,简单操作,易用,就是个url地址的get传值方式
代码如下:
using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Net;
using System.IO;
using System.Text;
/// <summary>
///HttpInvoker 的摘要说明
/// </summary>
public class HttpInvoker
{
public HttpInvoker()
{
//
//TODO: 在此处添加构造函数逻辑
//
}
/// <summary>
///
/// </summary>
/// <param name="userName">用户名</param>
/// <param name="password">密码</param>
/// <param name="mobile">发送手机号,多个号码使用半角逗号(,)分隔,如:13300000000,13300000001,13300000002</param>
/// <param name="content">发送内容,超过70字将拆成多条发送</param>
/// <returns></returns>
public static String sendMsg(string userName, string password, string mobile, string content)
{
String myParams = "commandID=3&username=" + userName +
"&password=" + password + "&mobile=" + mobile + "&content=" +
content;
String result = HttpInvoker.post(myParams);
return result;
}
public static String post(String myParams)
{
HttpWebRequest myReq = (HttpWebRequest)HttpWebRequest.Create("http://61.156.38.47:8080/CPDXT/SendSms");
myReq.Method = "POST";
myReq.ContentType = "application/x-www-form-urlencoded";
try
{
Stream myRequestStream = myReq.GetRequestStream();
StreamWriter myStreamWriter = new StreamWriter(myRequestStream, Encoding.Default);
myStreamWriter.Write(myParams);
myStreamWriter.Close();
myRequestStream.Close();
HttpWebResponse myHttpWebResponse = (HttpWebResponse)myReq.GetResponse();
if (myHttpWebResponse != null && myHttpWebResponse.StatusCode == HttpStatusCode.OK)
{
Stream myResponseStream = myHttpWebResponse.GetResponseStream();
StreamReader myStreamReader = new StreamReader(myResponseStream, Encoding.Default);
String result = myStreamReader.ReadToEnd();
//把数据从HttpWebResponse的Response流中读出
myStreamReader.Close();
myResponseStream.Close();
return result;
}
else
{
return myHttpWebResponse == null ? "网络异常" : "myHttpWebResponse.StatusCode";
}
}
catch (Exception ex)
{
return "网络异常";
}
}
}
调用
String result = HttpInvoker.sendMsg("账号", "密码", 发送手机,
"亲,你好,我们是铁青旅行社,您的" + trade_no+TravelTitle +
"已经通过审核,请到支付宝确认订单,最后祝您旅游开心!");
if ("return=0;".Equals(result))
{
Response.Write("<script type=‘text/javascript‘>alert(‘短信发送成功!‘);</script>");
}
else
{
Response.Write("<script type=‘text/javascript‘>alert(‘短信发送失败!‘);</script>");
}
//Response.Write("返回参数:" + result);
//Response.Write("<script type=‘text/javascript‘>alert(‘返回参数:"+ result+"‘);</script>");
标签:div ati creat control res hold fresh www 内容
原文地址:http://www.cnblogs.com/wanzhongjun/p/6876340.html