473,721 Members | 4,027 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

VB.Net System.Net - Cookies - Form Submit

IonutZ
7 New Member
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, SOMEEMAILADDRES S@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 9397
AricC
1,892 Recognized Expert Top Contributor
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, SOMEEMAILADDRES S@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 New Member
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 New Member
bumpity bump bump
opyo
o s
s t
t
Mar 12 '07 #4
kenobewan
4,871 Recognized Expert Specialist
Here is an article that may help:
ASP.NET Cookies
Mar 12 '07 #5
IonutZ
7 New Member
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 Recognized Expert Specialist
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

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

Similar topics

0
2744
by: victor | last post by:
Hi, I used Cookies to store username. In a Windows98 client, I typed some Chinese characters into the login box in login.asp. After submit, in c.asp, the username is stored in the cookies. The original username and the one got back from the cookies are displied in c.asp, they are different! Use WindowsXP client will be fine.
20
3545
by: Brian Burgess | last post by:
Hi all, Anyone know if this is possible? If so, on which page would the cookie be? .. On the page calling a function defined in the include file? thanks in advance.. -BB
7
2994
by: Brian Burgess | last post by:
Hi all, Anyone see anything wrong with the following: *************************************************************** <%@ LANGUAGE="VBSCRIPT" %> <% Option Explicit Dim nAcctNbr Dim nMsgStart
0
1499
by: collie | last post by:
i need to create 2 separate cookies in asp to be read later on in asp.net. I need to create an ADMIN cookie and a User cookie. In my database i have a table called users. if the field ACCESS=admin then i need to create an admin cookie if ACCESS =user then i need to create a user cookie. The page is redirected to an aspx page where it reads the cookie. if the cookie is admin then access to the entire site should be possible otherwise access...
4
5388
by: Fred | last post by:
Hi, i know how to pass a value from Javascript to ASP with a hidden field into a form and submitting it, or with cookies, but here i have to pass a lot of data in an array. There is a list of product the visitor can order by clicking one or more checkboxes. I made a form containing input with type "checkbox" like: <form> <input type="checkbox" name=ck id=ck
2
6952
by: Luis Esteban Valencia Muñoz | last post by:
I'm working on a web scraping application that needs to log into a website before it can get the data to scrape. I've always been confused about how the HttpWebRequest and HttpWebResponse objects work together with cookies, and was hoping that someone here could clear it up for me! Here's the steps I need to accomplish: 1) Set two cookies containing information I already have 2) Request the login page URL, and save a third cookie that...
6
6446
by: Paul | last post by:
Here is a question that should get everyone going. I have an ecommerce site where I need to pass the order_id to every page. So which method is the best practice to pass this variable between pages: Cookies or Session variable or by the HTTP header (either GET querystring or POST form)? I do not like to use sessions because they time out after 20 minutes of inactivity.
0
1708
by: Claudio | last post by:
I have a demo app where cookies does not work. The first page create a cookies. The second read the contet. If I browse the pages via IE6.0 the pages does not work. If I browse the pages via FireFox the pages work fine. ************ SetCookies.asp <%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
4
2774
by: Jon Slaughter | last post by:
I have developed a technique to add and remove cookies after output... wondering if there is something else like this out there? Jon
0
8736
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
9143
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9077
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8019
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6676
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4497
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3202
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2588
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2137
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.