C#发送好友飞信

1、废话不多说,先上图:

image

2、实现代码:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        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;  
       }

        private void button2_Click(object sender, EventArgs e)
        {
            this.Close();
        }  
    }
}

3、亲测通过,但首先要加飞信好友才能使用,如果您有好的方法或者其它飞信实现的方法,请给我留言,非常感谢。

posted @ 2013-04-19 20:41  jikoy chiu  阅读(173)  评论(2编辑  收藏  举报