我这里以56短信接口为例!

  1. 首先需要到56短信网上去注册个账号,代码中需要用到4个参数:企业ID、用户名、密码、所用平台

  2. 在里面充钱配合下面的代码就可以发送短信啦!

        public void Send(string orderIDs, string mobile, string productName)
        {

             //下文中的tel:就是要发送的手机号码

             //msg:要发送的内容
            //发送短信
            string cid = "1345";//企业号ID
            string username = "test15";//用户名
            string userpwd = "test15333";//密码
            string mssage = "订单提交成功!";
            string _sms = "10690";//平台
            string msg = "您的订单已提交成功!" + "订单号:(" + orderIDs + ")商品名称:" + productName + "【公司名称】";
            msg = HttpUtility.UrlEncode(msg, System.Text.Encoding.GetEncoding("gbk"));//由于网站是utf-8编码,要进行一下转码,不然会是乱码,调用webs的不用转码
            string tel = mobile;
            string url = "http://jiekou.56dxw.com/sms/HttpInterface.aspx?comid=" + cid + "&username=" + username + "&userpwd=" + userpwd + "&handtel=" + tel + "&sendcontent=" + msg + "&sendtime=&smsnumber=" + _sms + "";
            WebRequest wRequest = WebRequest.Create(url);
            WebResponse wResponse = wRequest.GetResponse();
            Stream stream = wResponse.GetResponseStream();
            StreamReader reader = new StreamReader(stream, System.Text.Encoding.Default);
            string r = reader.ReadToEnd();
            wResponse.Close();

            ScriptUtil.Instance.Alert(mssage);
        }

延伸阅读:

导读:  我们只提供asp.net调用56短信接口核心代码,针对不同的网站,系统,可做相应的修改. 此接口一次只能发送一个手机号码,如需要给多次发送,可循环,或调用HttpInterfaceMore.aspx 和WebService文件接口,此源码只适用56短信接口,对其它的不是本公司开发的接口,出现问题,我们不做技术支持.




我们只提供核心代码,针对不对的平台,可做相应的修改.
此接口一次只能发送一个手机号码,如需要给多次发送,可循环,或调用HttpInterfaceMore.aspx 和WebService文件接口

 

内容如果是乱码,请编码,如:

string message = "中华人民共和国";
message = HttpUtility.UrlEncode(message, System.Text.Encoding.GetEncoding("GB2312"));
 
需要引用名命空间:

using System.Text;
using System.IO;
using System.Net;

代码如下:

public string HttpInterface()
{
string url="http://jiekou.56dxw.com/sms/HttpInterface.aspx?comid=企业ID&username=用户名&userpwd=密码&handtel=手机号

&sendcontent=内容限制为70个字&sendtime=定时时间&smsnumber=所用平台"

            WebRequest wRequest = WebRequest.Create(url);
            WebResponse wResponse = wRequest.GetResponse();
            Stream stream = wResponse.GetResponseStream();
            StreamReader reader = new StreamReader(stream, System.Text.Encoding.Default);
            string r = reader.ReadToEnd();
            wResponse.Close();

     }

更详情请阅读查看官网:http://www.56dxw.com/Interface/150.html