TehEpidemick
BANNED
- Oct 31, 2011
- 778
- 183
I am trying to login to facebook using httpwebrequests. My problem is an error on facebook login stating
"Cookies RequiredCookies are not enabled on your browser. Please adjust this in your security preferences before continuing."
If anyone has any idea it would be amazing.
Tehepidemick.
"Cookies RequiredCookies are not enabled on your browser. Please adjust this in your security preferences before continuing."
Code:
Imports System.NetImports System.Text
Imports System.IO
Public Class Form1
Dim logincookie As CookieContainer
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim postdata As String = "lsd=AVrEI81J&email=&pass=&default_persistent=0&timezone=240&lgnrnd=180955_8SwZ&lgnjs=1375751401&locale=en_US"
Dim tempcookies As New System.Net.CookieContainer
Dim encoding As New UTF8Encoding
Dim bytedata As Byte() = encoding.GetBytes(postdata)
Dim postreq As HttpWebRequest = DirectCast(WebRequest.Create("https://www.facebook.com/login.php?login_attempt=1"), HttpWebRequest)
postreq.CookieContainer = tempcookies
postreq.Method = "POST"
postreq.KeepAlive = True
postreq.ContentType = "application/x-www.form-urlencoded"
postreq.Referer = "https://www.facebook.com/login.php?login_attempt=1"
postreq.UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.95 Safari/537.36"
postreq.ContentLength = bytedata.Length
Dim postreqstream As Stream = postreq.GetRequestStream()
postreqstream.Write(bytedata, 0, bytedata.Length)
postreqstream.Close()
Dim postresponse As HttpWebResponse
postresponse = DirectCast(postreq.GetResponse(), HttpWebResponse)
tempcookies.Add(postresponse.Cookies)
logincookie = tempcookies
Dim postreqreader As New StreamReader(postresponse.GetResponseStream())
Dim thepage As String = postreqreader.ReadToEnd
RichTextBox1.Text = thepage
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
WebBrowser1.DocumentText = RichTextBox1.Text
End Sub
End Class
If anyone has any idea it would be amazing.
Tehepidemick.