標籤:facebook註冊機 facebook帳號註冊 csharp程式碼範例 facebook註冊.net代碼
【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