飞信免费发短信API接口在线演示: http://sms.api.bz/
飞信免费发短信API接口调用方式(通过HTTP访问以下网址、支持GET和POST):
官方给出的例子:
http://sms.api.bz/fetion.php?username=13800138000&password=123456&sendto=13912345678&message=短信内容
注:短信内容最大长度为180个汉字,超过180个汉字不发送。返回的信息为UTF-8编码的中文文本信息。
下面例子要添加如下命名空间:
using System.Net; //Web服务命名空间
/// <summary> /// 发送飞信 /// </summary> /// <param name="strUser">用户名</param> /// <param name="strPwd">用户密码</param> /// <param name="strTel">收信人手机号</param> /// <param name="strMessage">发送内容</param> private void SendMessage(string strUser, string strPwd, string strTel, string strMessage) { string url = "http://sms.api.bz/fetion.php?username=" + strUser + "&password=" + strPwd + "&sendto=" + strTel + "&message=" + strMessage; HttpWebRequest hwr = (HttpWebRequest)HttpWebRequest.Create(url); hwr.Method = "GET"; try { HttpWebResponse wr = (HttpWebResponse)hwr.GetResponse(); if (wr.StatusCode == HttpStatusCode.OK) { MessageBox.Show("发送成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); StoreHistory("短信", strTel, "发送成功"); } else { MessageBox.Show("发送失败:" , "错误信息", MessageBoxButtons.OK, MessageBoxIcon.Error); StoreHistory("短信", strTel, "发送失败"); } } catch(Exception ex) { MessageBox.Show("发送失败:" + ex.Message, "错误信息", MessageBoxButtons.OK, MessageBoxIcon.Error); StoreHistory("短信", strTel, "发送失败"); } }
该实例下载地址:
http://download.csdn.net/source/2232920
希望,对大家有用!