【Facebook注册机_Facebook账号注册_Csharp代码示例_.Net代码】
朋友叫了很久帮忙写,无奈今天花时间研究下。。。。
下面只是一个简单示例,
里面我写有一些类,对于写注册机之类的,或许有帮助哟!!
======================================
注册是成功了,可登录发现跳出手机验证。。。。
部分代码:
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading; using System.Windows.Forms; namespace Register { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { button1.Enabled = false; Notify("*********开始**********", 2); //设置参数 string xing = EnVon.Helper.ChineseHelper.GetXing(); string ming = EnVon.Helper.ChineseHelper.GetMing(2); string email = Helper.ChineseHelper.GetPinYin(xing + ming).ToLower() + Helper.StringHelper.GetEmailDomain(); string password = EnVon.Helper.StringHelper.RndString(4) + EnVon.Helper.StringHelper.RndString(5, 1); string birYear = Helper.StringHelper.RndNumberS(1980, 1996); string birMonth = Helper.StringHelper.RndNumberS(1, 13); string birDay = Helper.StringHelper.RndNumberS(1, 29); string retData = string.Empty; //创建对象 Facebook.Register reg = new Facebook.Register() { birthday_day = birDay, //生日日 birthday_month = birMonth, //生日月 birthday_year = birYear, //生日年 firstname = ming, //名字 lastname = xing, //姓 reg_email__ = email, //邮箱 reg_email_confirmation__ = email, //确认邮箱 reg_passwd__ = password //密码 }; //打开注册页 Notify("打开注册页。。。"); int retB = reg.OpenRegPage(); if (retB == 0) { Thread.Sleep(200); Notify("提交注册表单。。。"); //提交注册 retB = reg.PostForm(out retData); if (retB == 0) { Notify("恭喜,注册成功!!"); Notify("-----------------------------"); Notify("姓名:" + xing + ming); Notify("邮箱:" + email); Notify("密码:" + password); Notify("生日:" + birYear + "-" + birMonth + "-" + birDay); Notify("-----------------------------"); } else if (retB == 1) { Notify("注册失败!"); Notify("失败原因:邮箱已注册过!"); } else { Notify("注册失败!"); Notify("失败原因:" + reg.GetErrMessage(retData)); } rtxtData.Text = retData; } else { Notify("打开注册页失败!"); } Notify("*********完毕**********"); button1.Enabled = true; } private void button2_Click(object sender, EventArgs e) { } private void Notify(string str, int mode = 8) { if (mode == 8) { rtxtMain.Text += DateTime.Now + " " + str + "\r\n"; } else { rtxtMain.Text = DateTime.Now + " " + str + "\r\n"; } } private void Form1_Load(object sender, EventArgs e) { this.Text = "Facebook账号注册示例"; } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Facebook { /// <summary> /// Facebook账号注册 /// </summary> public class Register { private Random RND = new Random(); private EnVon.HttpRequest http = null; #region 注册的参数 public string lastname { get; set; } public string firstname { get; set; } public string reg_email__ { get; set; } public string reg_email_confirmation__ { get; set; } public string reg_passwd__ { get; set; } public string birthday_year { get; set; } public string birthday_month { get; set; } public string birthday_day { get; set; } private string lsd { get; set; } private string sex { get { return string.Empty + RND.Next(1, 3); } set { } } private string referrer { get; set; } private string asked_to_login { get; set; } private string terms { get; set; } private string ab_test_data { get; set; } private string contactpoint_label { get; set; } private string locale { get; set; } private string abtest_registration_group { get; set; } private string reg_instance { get; set; } private string captcha_persist_data { get; set; } private string captcha_session { get; set; } private string extra_challenge_params { get; set; } private string recaptcha_type { get; set; } private string captcha_response { get; set; } private string ignore { get; set; } private string __user { get; set; } private string __a { get; set; } private string __dyn { get; set; } private string __req { get; set; } private string __rev { get; set; } #endregion public Register() { __req = "5"; //__dyn = "7wiXwNAwsUKEkzoynFwh8"; __a = "1"; __user = "0"; ignore = "captcha"; captcha_response = ""; recaptcha_type = "password"; abtest_registration_group = "1"; locale = "zh_CN"; contactpoint_label = "email_only"; terms = "on"; asked_to_login = "0"; referrer = ""; http = new EnVon.HttpRequest(); http.UserAgent = "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.3; WOW64; Trident/7.0)"; } /// <summary> /// 打开注册页并获取部分参数 /// </summary> /// <returns></returns> public int OpenRegPage() { string url = "https://www.facebook.com/"; string data = http.GetData(url, "utf-8"); if (data.Length > 100) { var arr = Helper.StringHelper.MidMulti(data, "<input", ">"); __rev = Helper.StringHelper.Mid(data, "\"revision\":", ","); //ab_test_data = "AAAP/P/f/fAAPAAAfAAPfAAAPAAAfAPAAAAAAAAAO/VMEAACCCOBBM";//??? captcha_persist_data = GetInputValue(arr, "captcha_persist_data"); captcha_session = GetInputValue(arr, "captcha_session"); extra_challenge_params = GetInputValue(arr, "extra_challenge_params"); lsd = GetInputValue(arr, "lsd"); reg_instance = GetInputValue(arr, "reg_instance"); return 0; } return 1; } /// <summary> /// 提交注册表单 /// </summary> /// <returns></returns> public int PostForm(out string html) { int retB = -1; string pUrl = "https://www.facebook.com/ajax/register.php"; string pRef = "https://www.facebook.com/"; string pData = string.Empty; //拼接pData Dictionary<string, string> dicParams = new Dictionary<string, string>(); dicParams.Add("__a", __a); dicParams.Add("__dyn", __dyn); dicParams.Add("__req", __req); dicParams.Add("__rev", __rev); dicParams.Add("__user", __user); dicParams.Add("ab_test_data", ab_test_data); dicParams.Add("abtest_registration_group", abtest_registration_group); dicParams.Add("asked_to_login", asked_to_login); dicParams.Add("birthday_day", birthday_day); dicParams.Add("birthday_month", birthday_month); dicParams.Add("birthday_year", birthday_year); dicParams.Add("captcha_persist_data", captcha_persist_data); dicParams.Add("captcha_response", captcha_response); dicParams.Add("captcha_session", captcha_session); dicParams.Add("contactpoint_label", contactpoint_label); dicParams.Add("extra_challenge_params", extra_challenge_params.Replace("&", "&")); dicParams.Add("firstname", firstname); dicParams.Add("ignore", ignore); dicParams.Add("lastname", lastname); dicParams.Add("locale", locale); dicParams.Add("lsd", lsd); dicParams.Add("recaptcha_type", recaptcha_type); dicParams.Add("referrer", referrer); dicParams.Add("reg_email__", reg_email__); dicParams.Add("reg_email_confirmation__", reg_email_confirmation__); dicParams.Add("reg_instance", reg_instance); dicParams.Add("reg_passwd__", reg_passwd__); dicParams.Add("sex", sex); dicParams.Add("terms", terms); foreach (string item in dicParams.Keys) { pData += (pData.Length > 0 ? "&" : "") + item + "=" + Helper.StringHelper.UrlEncode(dicParams[item]); } //提交数据 html = http.PostData(pUrl, pData, "utf-8", pRef); if (html.IndexOf("registration_succeeded\":true") > 0) { if (html.IndexOf("redirect\":\"\\/register\\/confirm.php") > 0) { retB = 1;//邮箱已注册过 } else { retB = 0;/*注册成功*/ } } return retB; } /// <summary> /// 取错误提示信息 /// </summary> /// <param name="retData"></param> /// <returns></returns> public string GetErrMessage(string retData) { string str = EnVon.Helper.StringHelper.UnicodeDecode(retData); str = Helper.StringHelper.FiltHtml(str); str = Helper.StringHelper.Mid(str, "{\"__html\":\"", "\"},\"error_code"); return str; } private string GetInputValue(List<string> list, string name) { string str = string.Empty; foreach (string item in list) { if (item.IndexOf("name=\"" + name + "\"") > 0) { str = Helper.StringHelper.Mid(item,"value=\"","\"" ); break; } } return str; } } }
使用VS2013编写,源码下载:
http://download.csdn.net/detail/envon123/7327619
=========================================================
END
Facebook注册机_Facebook账号注册_Csharp代码示例_.Net代码_VS2013,布布扣,bubuko.com
时间: 2024-10-13 16:43:22