472,145 Members | 1,574 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,145 software developers and data experts.

VB.Net System.Net - Cookies - Form Submit

IonutZ
7
Hi guys,

This is what I'm trying to achieve:
  • Login to Facebook via system.net

I've already achieved login through AxWebBrowser... but then I don't know how to disable sound / images / javascript and I occasionally get a JS error which is not cool...

But via System.NET I don't know how to work with cookies... This is what I've got so far (where I'm stuck)


Expand|Select|Wrap|Line Numbers
  1. Public Class Form1
  2.     Dim web As New System.Net.WebClient()
  3.     Dim james As New System.Net.Cookie
  4.  
  5.     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  6.  
  7.         web.Headers.Add("Content-Type", "application/x-www-form-urlencoded")
  8.         web.Headers.Add(Net.HttpRequestHeader.UserAgent, "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)")
  9.  
  10.         Dim d As Byte() = System.Text.Encoding.ASCII.GetBytes("email=SOMEEMAILADDRESS@comcast.net")
  11.  
  12.         Dim res As Byte() = web.UploadData("https://login.facebook.com/login.php", "POST", d)
  13.  
  14.         txtCool.text = System.Text.Encoding.ASCII.GetString(res)
  15.     End Sub
  16.  
  17. End Class
  18.  
This is how the cookie IE7 makes, looks like:

Expand|Select|Wrap|Line Numbers
  1. __qca
  2. 1172665088-900161-52902507
  3. facebook.com/
  4. 1600
  5. 2350186496
  6. 32111674
  7. 2186409104
  8. 29842226
  9. *
  10. login
  11. ionutz%40comcast.net
  12. facebook.com/
  13. 9728
  14. 1022930048
  15. 29867537
  16. 744132816
  17. 29844254
  18. *
  19.  
This was much easier in VB 6, but I decided to step it up and try to do it in VB.Net...

What I don't know how to do:
  • Add more variables to the post string
  • How to show facebook through system.net that I "have cookies enabled"
  • How to login haha


And as you can tell, SOMEEMAILADDRESS@comcast.net is my e-mail... so if anyone could help, i'd be super-thankful.

The purpose of this program is - pure personal use, I want to make a program that checks for messages on facebook at a given interval of time and will warn me when I get one!

Thanks and looking forward to your reply!
Mar 10 '07 #1
6 9290
AricC
1,892 Expert 1GB
Hi guys,

This is what I'm trying to achieve:
  • Login to Facebook via system.net

I've already achieved login through AxWebBrowser... but then I don't know how to disable sound / images / javascript and I occasionally get a JS error which is not cool...

But via System.NET I don't know how to work with cookies... This is what I've got so far (where I'm stuck)


Expand|Select|Wrap|Line Numbers
  1. Public Class Form1
  2.     Dim web As New System.Net.WebClient()
  3.     Dim james As New System.Net.Cookie
  4.  
  5.     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  6.  
  7.         web.Headers.Add("Content-Type", "application/x-www-form-urlencoded")
  8.         web.Headers.Add(Net.HttpRequestHeader.UserAgent, "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)")
  9.  
  10.         Dim d As Byte() = System.Text.Encoding.ASCII.GetBytes("email=SOMEEMAILADDRESS@comcast.net")
  11.  
  12.         Dim res As Byte() = web.UploadData("https://login.facebook.com/login.php", "POST", d)
  13.  
  14.         txtCool.text = System.Text.Encoding.ASCII.GetString(res)
  15.     End Sub
  16.  
  17. End Class
  18.  
This is how the cookie IE7 makes, looks like:

Expand|Select|Wrap|Line Numbers
  1. __qca
  2. 1172665088-900161-52902507
  3. facebook.com/
  4. 1600
  5. 2350186496
  6. 32111674
  7. 2186409104
  8. 29842226
  9. *
  10. login
  11. ionutz%40comcast.net
  12. facebook.com/
  13. 9728
  14. 1022930048
  15. 29867537
  16. 744132816
  17. 29844254
  18. *
  19.  
This was much easier in VB 6, but I decided to step it up and try to do it in VB.Net...

What I don't know how to do:
  • Add more variables to the post string
  • How to show facebook through system.net that I "have cookies enabled"
  • How to login haha


And as you can tell, SOMEEMAILADDRESS@comcast.net is my e-mail... so if anyone could help, i'd be super-thankful.

The purpose of this program is - pure personal use, I want to make a program that checks for messages on facebook at a given interval of time and will warn me when I get one!

Thanks and looking forward to your reply!
I edited your post providing your email address in that format is a great way to get spammed.
Mar 11 '07 #2
IonutZ
7
I edited your post providing your email address in that format is a great way to get spammed.
Thanks, didn't realize this site was spidered, but then, I got to it by googling.... so - it makes sense =)
Mar 11 '07 #3
IonutZ
7
bumpity bump bump
opyo
o s
s t
t
Mar 12 '07 #4
kenobewan
4,871 Expert 4TB
Here is an article that may help:
ASP.NET Cookies
Mar 12 '07 #5
IonutZ
7
Nope, that doesn't really help because I'm trying to extract / emulate a cookie with the webclient .net component...

Thanks tho... anyone have any other ideas?
Mar 12 '07 #6
kenobewan
4,871 Expert 4TB
Here is a post trying to do something similar:
WebClient timeout

While this is not helpful either, I believe it illustrates a difference between VB6 & vb.net in trying to manage sessionstate for the project. In relation to webclient, I believe that there is class and not a component - unless you create one using the class. Here is an example:
Screen Scrapes in ASP.NET

So I don't believe that you can directly migrate a VB6 webclient component to asp.net the way that you would like. That is why the earlier article I referenced referred you to the handling of sessionstate through cookies. Here is an article that may prove me wrong:
Download a Web Page using the WebClient

I hope that this is helpful.
Mar 13 '07 #7

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

20 posts views Thread by Brian Burgess | last post: by
7 posts views Thread by Brian Burgess | last post: by
reply views Thread by collie | last post: by
2 posts views Thread by Luis Esteban Valencia Muñoz | last post: by
4 posts views Thread by Jon Slaughter | last post: by
reply views Thread by Saiars | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.