WinHttpRequest "Push Button"

So, I know how to do this:

    WebBrowser2.Navigate ("http://www.website.com")
    WebBrowser2.Document.All.Item("userid").Value = "myuserid"

But how do I do this:

    Dim http As WinHttpRequest
    Set http = New WinHttpRequest

    http.Open "GET", "http://www.website.com", "False"
    http.Send

     The above all works fine, then I need to somehow:

     http.Document.All.Item("userid").Value = "myuserid"

Anyone know?
hrolsonsAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

JezWaltersCommented:
Are you talking about using the POST method, instead of the GET method?
Dim htpRequest As WinHttp.WinHttpRequest

Set htpRequest = New WinHttp.WinHttpRequest
htpRequest.Open "POST", "http://www.website.com", False
htpRequest.Send "userId=myuserid"

Open in new window

0
JezWaltersCommented:
You might need to set the SetRequestHeader property too ...
0
hrolsonsAuthor Commented:
OK, so I set my username & password, how do I click "Submit"?
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

JezWaltersCommented:
The easiest way to figure out what traffic to send is to monitor what happens when you log in manually - I used Fiddler & Internet Explorer to do this.

    http://www.fiddler2.com/fiddler2

If you tell me the exact URL you're using to log in, then I should be able to work it out for you.
0
hrolsonsAuthor Commented:
I will have a look at Fiddler.  I've been using FireBug& Firexox to find the names of the elements.

The site is:

http://winkflash.com/
0
JezWaltersCommented:
It looks like you need to specify a few more arguments in your POST request.  I'm not sure yet if you need all of these, but this should log you in (it works for me anyway!):
Const WEBSITE As String = "http://www.winkflash.com/photo/signin.aspx"
Const USERID As String = "UserName"
Const PASSWORD As String = "Password"

Dim htpRequest As WinHttp.WinHttpRequest

Set htpRequest = New WinHttp.WinHttpRequest
htpRequest.Open "POST", WEBSITE, False   ' Synchronously
htpRequest.SetRequestHeader "Content-Type", "application/x-www-form-urlencoded"
htpRequest.Send "__VIEWSTATE=%2FwEPDwUJOTk0MjUzNjUwD2QWAgIDD2QWAgIBDw8WAh4LTmF2aWdhdGVVcmwFC3NpZ251cC5hc3B4ZGQYAQUeX19Db250cm9sc1JlcXVpcmVQb3N0QmFja0tleV9fFgEFC2Noa1JlbWVtYmVy6e5Vs%2BpiC56sIiBjrkn4HfS56wI%3D" & _
                "&__EVENTVALIDATION=%2FwEWBwLXz7LSBgLi%2BtIuAuv3gd4CAv2gg9wGAvK94JEPAoznisYGAtHnkYkOkrqdf4hn3msK%2Ba5taAY0gMoCpN8%3D&siteid=1" & _
                "&userid=" & USERID & _
                "&password=" & PASSWORD & _
                "&Button1=Log+In"
Debug.Print htpRequest.ResponseText

Set htpRequest = Nothing

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
JezWaltersCommented:
The __VIEWSTATE and __EVENTVALIDATION parameter values are entirely specific to the winkflash website, so you'd have to contact them for their precise meaning - but you can't log in without them.

Let me know if you'd like me to take you through the steps I used to figure this out!  :-)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.