使用飞信api接口实现短信发送(只能发送好友)
2024-10-18 20:00:49
找了很久才找到一个能用的飞信API接口(http://quanapi.sinaapp.com/fetion.php?u=飞信登录手机号&p=飞信登录密码&to=接收飞信的手机号&m=飞信内容),不过是第三方的API接口,飞信官方是没有发布API接口的,正在做一个环境监测系统,需要用到短信报警功能,当然使用短信猫也可以实现,不过毕竟能省则省,话不多说,这是我用C#写的一个程序:
1.界面如下
2.代码
- private void button1_Click(object sender, EventArgs e)
- {
- string fno = textBox_fno.Text; //发件人的号码
- string fp = textBox_fp.Text; //发件人密码
- string fto = textBox_fto.Text; //收件人号码
- string fm = textBox_fm.Text; //短信内容
- fm = UrlEncode(fm);
- string url = "http://quanapi.sinaapp.com/fetion.php?u=" + fno + "&p=" + fp + "&to=" + fto + "&m=" + fm;//破解API
- string res = getContent(url);
- MessageBox.Show("短信发送成功!");
- }
private void button1_Click(object sender, EventArgs e)
{
string fno = textBox_fno.Text; //发件人的号码
string fp = textBox_fp.Text; //发件人密码
string fto = textBox_fto.Text; //收件人号码
string fm = textBox_fm.Text; //短信内容
fm = UrlEncode(fm);
string url = "http://quanapi.sinaapp.com/fetion.php?u=" + fno + "&p=" + fp + "&to=" + fto + "&m=" + fm;//破解API
string res = getContent(url);
MessageBox.Show("短信发送成功!");
}
- public static string UrlEncode(string str)
- {
- StringBuilder sb = new StringBuilder();
- byte[] byStr = System.Text.Encoding.Default.GetBytes(str); //
- for (int i = 0; i < byStr.Length; i++)
- {
- sb.Append(@"%" + Convert.ToString(byStr[i], 16));
- }
- return (sb.ToString());
- }
- private static string getContent(string Url)
- {
- string strResult = "";
- try
- {
- HttpWebRequest request = (HttpWebRequest)WebRequest.Create(Url);
- //声明一个HttpWebRequest请求
- request.Timeout = 30000;
- //设置连接超时时间
- request.Headers.Set("Pragma", "no-cache");
- HttpWebResponse response = (HttpWebResponse)request.GetResponse();
- Stream streamReceive = response.GetResponseStream();
- Encoding encoding = Encoding.GetEncoding("GB2312");
- StreamReader streamReader = new StreamReader(streamReceive, encoding);
- strResult = streamReader.ReadToEnd();
- streamReader.Close();
- }
- catch
- {
- throw;
- }
- return strResult;
- }
最新文章
- 【MySQL】drop大表
- Spring中常用的连接池配置
- MySQL数据库备份命令
- 《JavaScript权威指南》学习笔记 第七天 DOM操作
- WPF标准控件模板查看程序(文件里面)
- zw版【转发&#183;台湾nvp系列Delphi例程】HALCON OverpaintRegion1
- javascript 中根据sort 方法随机数组 (Math.random)
- .net分页控件webdiyer:AspNetPager
- IOS cocos2d笔记1
- 1628. White Streaks(STL)
- 用android LinearLayout和RelativeLayout实现精确布局(转)
- Linux C语言操作MySQL
- 通过NSURL获取网络标准时间
- 通过sql查找指定字段存在哪些表中
- Cs231n课堂内容记录-Lecture2-Part1 图像分类
- 正态分布-python建模
- MT【241】红蓝两色染色
- 007-atomic包的原理及分析
- hdu2732 Leapin&#39; Lizards 最大流+拆点
- 免费SSL证书申请 2018年至简教程
热门文章
- MVC传值方式及优缺点
- bzoj 3876 [Ahoi2014]支线剧情(有上下界的最小费用流)
- 《A First Course in Probability》-chaper4-离散型随机变量-负二项分布
- 病毒侵袭 - HDU 2896(AC自动机)
- poj2325
- Windows的应用管理工具 PortableApps,Chocolatey和Ninite
- paip.输入法编程----删除双字词简拼
- Android自动化测试之monkeyrunner工具
- Cocos2d-x 3.0 实例学习教程 前沿
- C++中模板类使用友元模板函数