找了很久才找到一个能用的飞信API接口(http://quanapi.sinaapp.com/fetion.php?u=飞信登录手机号&p=飞信登录密码&to=接收飞信的手机号&m=飞信内容),不过是第三方的API接口,飞信官方是没有发布API接口的,正在做一个环境监测系统,需要用到短信报警功能,当然使用短信猫也可以实现,不过毕竟能省则省,话不多说,这是我用C#写的一个程序:

1.界面如下

2.代码

  1. private void button1_Click(object sender, EventArgs e)
  2. {
  3. string fno = textBox_fno.Text; //发件人的号码
  4. string fp = textBox_fp.Text; //发件人密码
  5. string fto = textBox_fto.Text; //收件人号码
  6. string fm = textBox_fm.Text; //短信内容
  7. fm = UrlEncode(fm);
  8. string url = "http://quanapi.sinaapp.com/fetion.php?u=" + fno + "&p=" + fp + "&to=" + fto + "&m=" + fm;//破解API
  9. string res = getContent(url);
  10. MessageBox.Show("短信发送成功!");
  11. }
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("短信发送成功!");
}
  1. public static string UrlEncode(string str)
  2. {
  3. StringBuilder sb = new StringBuilder();
  4. byte[] byStr = System.Text.Encoding.Default.GetBytes(str); //
  5. for (int i = 0; i < byStr.Length; i++)
  6. {
  7. sb.Append(@"%" + Convert.ToString(byStr[i], 16));
  8. }
  9. return (sb.ToString());
  10. }
  11. private static string getContent(string Url)
  12. {
  13. string strResult = "";
  14. try
  15. {
  16. HttpWebRequest request = (HttpWebRequest)WebRequest.Create(Url);
  17. //声明一个HttpWebRequest请求
  18. request.Timeout = 30000;
  19. //设置连接超时时间
  20. request.Headers.Set("Pragma", "no-cache");
  21. HttpWebResponse response = (HttpWebResponse)request.GetResponse();
  22. Stream streamReceive = response.GetResponseStream();
  23. Encoding encoding = Encoding.GetEncoding("GB2312");
  24. StreamReader streamReader = new StreamReader(streamReceive, encoding);
  25. strResult = streamReader.ReadToEnd();
  26. streamReader.Close();
  27. }
  28. catch
  29. {
  30. throw;
  31. }
  32. return strResult;
  33. }

最新文章

  1. 【MySQL】drop大表
  2. Spring中常用的连接池配置
  3. MySQL数据库备份命令
  4. 《JavaScript权威指南》学习笔记 第七天 DOM操作
  5. WPF标准控件模板查看程序(文件里面)
  6. zw版【转发&#183;台湾nvp系列Delphi例程】HALCON OverpaintRegion1
  7. javascript 中根据sort 方法随机数组 (Math.random)
  8. .net分页控件webdiyer:AspNetPager
  9. IOS cocos2d笔记1
  10. 1628. White Streaks(STL)
  11. 用android LinearLayout和RelativeLayout实现精确布局(转)
  12. Linux C语言操作MySQL
  13. 通过NSURL获取网络标准时间
  14. 通过sql查找指定字段存在哪些表中
  15. Cs231n课堂内容记录-Lecture2-Part1 图像分类
  16. 正态分布-python建模
  17. MT【241】红蓝两色染色
  18. 007-atomic包的原理及分析
  19. hdu2732 Leapin&#39; Lizards 最大流+拆点
  20. 免费SSL证书申请 2018年至简教程

热门文章

  1. MVC传值方式及优缺点
  2. bzoj 3876 [Ahoi2014]支线剧情(有上下界的最小费用流)
  3. 《A First Course in Probability》-chaper4-离散型随机变量-负二项分布
  4. 病毒侵袭 - HDU 2896(AC自动机)
  5. poj2325
  6. Windows的应用管理工具 PortableApps,Chocolatey和Ninite
  7. paip.输入法编程----删除双字词简拼
  8. Android自动化测试之monkeyrunner工具
  9. Cocos2d-x 3.0 实例学习教程 前沿
  10. C++中模板类使用友元模板函数