Real Software Forums
http://forums.realsoftware.com/

HTTPSocket WebSite Login
http://forums.realsoftware.com/viewtopic.php?f=13&t=39714
Page 1 of 1

Author:  sinner [ Wed Jul 06, 2011 9:47 am ]
Post subject:  HTTPSocket WebSite Login

Hello i was wondering i have a vary simple code in VB6 that logs into a website. I tryed the same in RB but it does not log into the webpage. Am i doing something wrong here?

VB
Private Sub Command1_Click()
WebBrowser1.Document.All("login_email").Value = Email.Text
WebBrowser1.Document.All("login_pass").Value = Password.Text
WebBrowser1.Document.All("submit_login").Click
End Sub

Private Sub Form_Load()
WebBrowser1.Silent = True
WebBrowser1.Navigate ("http://www.mediafire.com/")
End Sub


RB

Dim form As Dictionary
Dim Cookies , Data As String
Dim i As Integer
form = New Dictionary

form.value("login_email")=Email.Text
form.value("login_pass") = Password.Text

HTTPSocket1.SetFormData( form )
HTTPSocket1.Post( "http://www.mediafire.com/" )

For i = 0 To HTTPSocket1.pageHeaders.nameCount("set-cookie")-1
Cookies = Cookies + HTTPSocket1.PageHeaders.Value( i ) + "; "
Next

HTTPSocket1.SetRequestHeader( "Cookie", Cookies )

Author:  jlawrence [ Wed Jul 06, 2011 12:30 pm ]
Post subject:  Re: HTTPSocket WebSite Login

are you getting an error of some kind? I always recommend firing up wireshark and see what's going on behind the scenes in cases like this. Maybe an encoding problem or a hidden field that needs to be set.

it is standard http authentication? or a form on a page?
for standard http authentication see this discussion
http://forums.realsoftware.com/viewtopic.php?f=1&t=38186&start=0

otherwise for a form, your procedure seems to be correct provided you are returning all the necessary fields/cookies that the site is expecting.

one thing I do notice though that might be causing a problem, you should capture your pageheaders in the HeadersReceived event. The way you have it coded, it just flies through the "httpsocket1.post" and continues before the page is even delivered, so it probably is skipping right over your for-loop. Remember that httpsockets are asynchronous so you have to wait for results before you proceed.
Good luck

Page 1 of 1 All times are UTC - 5 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/