public string PostData(string URL, string postData, string referer) { string response = string.Empty; ChangeProxy(); //http.SetRequestHeader("Cookie", "PREF=ID=39a7dcb4769a70b5:U=01e856263f78e316:FF=0:TM=1310809062:LM=1311756586:GM=1:S=qiyaqpZc0QJwSHyD;NID=49=Ljnrtc5KZDOFfgRVn1Tt6G6MdaeISmX4vOzE7MSbouPD_4ze6OoSuCMWXlH0Jy7fnAlEYzdYxs4V7JP2DXnKgDxVQMKYY60yWoeCgFIwTL2WWBfmxJZNml5pYdudn5Zw;GAPS=1:tS3_AUBl7WpcKSXAXYMVdDiWuMdX0Q:rAR7mbwZ6PlPnJt-;GALX=7iQKVcsEdN4;GoogleAccountsLocale_session=en_GB;SID=DQAAAIUAAAD1r3xd8mtKrnHFMI4AdB1fuFDSG6YQ98V-_olltRKYgRSHMAgKC9eU88xa6oIay8EgmaV8PRZl1uxi_Q7Hx3etXAUCd42mHJph5YHU015yCzmHUoGdeVpzpFtvPc4xFpnu1Hl2PqXSN4tIlDAY_Qg6vs8I8eoWpiVPPXkLR1WaKcw54W9s1Yx1PxN7C5Nazmc;LSID=blogger|s.IN:DQAAAIYAAACEkfAmZiRHYaawY6Ol0Oguk5C58mprkWFDmf4StK2d_UZDRC6baudw3SoGKkQGBEsB4r2wRrklsK9O1XChX7Pj-UnTPMaDxSz4ADM5O69S-LQhLJx10-1kdeomZSC2NIOWxIpHhoWn1FPrpQrFDgisVLfVsHsjD7l5ASyaLzgzaIxx-XZfuQHaCRgnMRF09vo;[email protected];HSID=AuAY8LSZuG828am_4;SSID=AYAPgLxKQx6efsNxV;APISID=j799BJ0rwj5vK8S3/Aid730sB7T-6RWKbq;SAPISID=BnxZXhygC3cPGeSV/AVHrAqmtZgl16WiOi"); req.RemoveAllParams(); req.UsePost(); //req.Path = "/login.php?login_attempt=1"; req.AddHeader("Accept-Encoding", "gzip,deflate"); req.AddHeader("Accept-Charset", "ISO-8859-1,utf-8;q=0.7,*;q=0.7"); req.AddHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.1; rv:18.0) Gecko/20100101 Firefox/18.0"); req.AddHeader("Accept", "application/json,text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8, */*"); req.AddHeader("Connection", "keep-alive"); //req.AddHeader("Cookie", "PREF=ID=39a7dcb4769a70b5:U=01e856263f78e316:FF=0:TM=1310809062:LM=1311756586:GM=1:S=qiyaqpZc0QJwSHyD;NID=49=Ljnrtc5KZDOFfgRVn1Tt6G6MdaeISmX4vOzE7MSbouPD_4ze6OoSuCMWXlH0Jy7fnAlEYzdYxs4V7JP2DXnKgDxVQMKYY60yWoeCgFIwTL2WWBfmxJZNml5pYdudn5Zw;GAPS=1:tS3_AUBl7WpcKSXAXYMVdDiWuMdX0Q:rAR7mbwZ6PlPnJt-;GALX=7iQKVcsEdN4;GoogleAccountsLocale_session=en_GB;SID=DQAAAIUAAAD1r3xd8mtKrnHFMI4AdB1fuFDSG6YQ98V-_olltRKYgRSHMAgKC9eU88xa6oIay8EgmaV8PRZl1uxi_Q7Hx3etXAUCd42mHJph5YHU015yCzmHUoGdeVpzpFtvPc4xFpnu1Hl2PqXSN4tIlDAY_Qg6vs8I8eoWpiVPPXkLR1WaKcw54W9s1Yx1PxN7C5Nazmc;LSID=blogger|s.IN:DQAAAIYAAACEkfAmZiRHYaawY6Ol0Oguk5C58mprkWFDmf4StK2d_UZDRC6baudw3SoGKkQGBEsB4r2wRrklsK9O1XChX7Pj-UnTPMaDxSz4ADM5O69S-LQhLJx10-1kdeomZSC2NIOWxIpHhoWn1FPrpQrFDgisVLfVsHsjD7l5ASyaLzgzaIxx-XZfuQHaCRgnMRF09vo;[email protected];HSID=AuAY8LSZuG828am_4;SSID=AYAPgLxKQx6efsNxV;APISID=j799BJ0rwj5vK8S3/Aid730sB7T-6RWKbq;SAPISID=BnxZXhygC3cPGeSV/AVHrAqmtZgl16WiOi"); #region PostData string[] arrPostData = Regex.Split(postData, "&"); postDataDictionary.Clear(); foreach (string item in arrPostData) { try { postDataDictionary.Add(item.Split('=')[0], item.Split('=')[1]); } catch (Exception) { } } foreach (var item in postDataDictionary) { req.AddParam(item.Key, item.Value); } #endregion ///Set Referer if (!string.IsNullOrEmpty(referer)) { req.AddHeader("Referer", referer); } Chilkat.HttpResponse respUsingPostURLEncoded = http.PostUrlEncoded(URL, req); string ResponseLoginPostURLEncoded = respUsingPostURLEncoded.BodyStr; response = ResponseLoginPostURLEncoded; return(response); }
public bool LogoutChilkat(ref Chilkat.Http http) { try { string pageSource1 = http.QuickGetStr("http://www.facebook.com/"); if (pageSource1.Contains("\"h\"") && pageSource1.Contains("post_form_id") && pageSource1.Contains("fb_dtsg")) { string h = string.Empty; string post_form_id = string.Empty; string fb_dtsg = string.Empty; if (pageSource1.Contains("\"h\"")) { string strTemp = pageSource1.Substring(pageSource1.IndexOf("\"h\""), 200); string[] ArrTemp = strTemp.Split('"'); h = ArrTemp[3]; } if (pageSource1.Contains("post_form_id") && pageSource1.Contains("fb_dtsg")) { string strTemp = pageSource1.Substring(pageSource1.IndexOf("post_form_id"), 200); string[] ArrTemp = strTemp.Split('"'); post_form_id = ArrTemp[2]; fb_dtsg = ArrTemp[6]; } Chilkat.HttpRequest reqLogout = new Chilkat.HttpRequest(); reqLogout.UsePost(); //req.Path = "/login.php?login_attempt=1"; reqLogout.RemoveAllParams(); reqLogout.AddHeader("User-Agent", "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.16) Gecko/20110319 Firefox/3.6.16"); //req.SetFromUrl("http://www.facebook.com/login.php?login_attempt=1"); reqLogout.AddParam("post_form_id", post_form_id); reqLogout.AddParam("fb_dtsg", fb_dtsg); reqLogout.AddParam("ref", "mb"); reqLogout.AddParam("h", h); Chilkat.HttpResponse respUsingPostURLEncoded = http.PostUrlEncoded("http://www.facebook.com/logout.php", reqLogout); string ResponseLoginPostURLEncoded = respUsingPostURLEncoded.BodyStr; string pageSource12 = http.QuickGetStr("http://www.facebook.com/"); return true; } return false; } catch (Exception ex) { return false; Console.WriteLine(ex.Message); } }
public bool LogoutChilkat(ref Chilkat.Http http) { try { string pageSource1 = http.QuickGetStr("http://www.facebook.com/"); if (pageSource1.Contains("\"h\"") && pageSource1.Contains("post_form_id") && pageSource1.Contains("fb_dtsg")) { string h = string.Empty; string post_form_id = string.Empty; string fb_dtsg = string.Empty; if (pageSource1.Contains("\"h\"")) { string strTemp = pageSource1.Substring(pageSource1.IndexOf("\"h\""), 200); string[] ArrTemp = strTemp.Split('"'); h = ArrTemp[3]; } if (pageSource1.Contains("post_form_id") && pageSource1.Contains("fb_dtsg")) { string strTemp = pageSource1.Substring(pageSource1.IndexOf("post_form_id"), 200); string[] ArrTemp = strTemp.Split('"'); post_form_id = ArrTemp[2]; fb_dtsg = ArrTemp[6]; } Chilkat.HttpRequest reqLogout = new Chilkat.HttpRequest(); reqLogout.UsePost(); //req.Path = "/login.php?login_attempt=1"; reqLogout.RemoveAllParams(); reqLogout.AddHeader("User-Agent", "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.16) Gecko/20110319 Firefox/3.6.16"); //req.SetFromUrl("http://www.facebook.com/login.php?login_attempt=1"); reqLogout.AddParam("post_form_id", post_form_id); reqLogout.AddParam("fb_dtsg", fb_dtsg); reqLogout.AddParam("ref", "mb"); reqLogout.AddParam("h", h); Chilkat.HttpResponse respUsingPostURLEncoded = http.PostUrlEncoded("http://www.facebook.com/logout.php", reqLogout); string ResponseLoginPostURLEncoded = respUsingPostURLEncoded.BodyStr; string pageSource12 = http.QuickGetStr("http://www.facebook.com/"); return(true); } return(false); } catch (Exception ex) { return(false); Console.WriteLine(ex.Message); } }