boonhui78
asked on
Sending a HTTP Request using VB6
Hi all!
I need to send a HTTP request to a certain asp file on the internet so as to trigger a action like sending emails, etc...
how should i do it??
thanks a million
I need to send a HTTP request to a certain asp file on the internet so as to trigger a action like sending emails, etc...
how should i do it??
thanks a million
If that does not work, try this:
inet1.Execute "http://website.com/page.asp", "POST", "TEST=TEST", "Content-Type: application/x-www-form-url encoded"
inet1.Execute "http://website.com/page.asp", "POST", "TEST=TEST", "Content-Type: application/x-www-form-url
ASKER
hi shankarkrupa!
i forgot to mention that my application is actually an activex dll... so it doesnt have any forms
so is it possible to create this object at run time?
thanks
i forgot to mention that my application is actually an activex dll... so it doesnt have any forms
so is it possible to create this object at run time?
thanks
Of course, you can do it by latebinding...
Like this:
set inet1 = CreateObject("InetCtls.Ine t.1")
then all those code...
Maybe, it is better to first place the inet1.cancel before all those codes, after creating the object...
Like this:
set inet1 = CreateObject("InetCtls.Ine
then all those code...
Maybe, it is better to first place the inet1.cancel before all those codes, after creating the object...
Following is the code I use. it needs at least IE 5 installed. the function makes use of the XMLHTTP object...if you want you can adjust it to make use of early binding instead of late binding like in the example.
Private Function GetHTML(url) As String
Dim objXML As Object
Set objXML = CreateObject("Microsoft.XM LHTTP")
objXML.Open "GET", url, False
objXML.send
If (objXML.Status = 404) Then
GetHTML = "404 Error"
Else
GetHTML = objXML.responseText
End If
Set objXML = Nothing
End Function
It sends the http request, and will return you the contents of that url, or a 404 error. The 404 error can be replaced by an err.raise, but that's all up to you to design it the way you want it to.
regards,
CJ
Private Function GetHTML(url) As String
Dim objXML As Object
Set objXML = CreateObject("Microsoft.XM
objXML.Open "GET", url, False
objXML.send
If (objXML.Status = 404) Then
GetHTML = "404 Error"
Else
GetHTML = objXML.responseText
End If
Set objXML = Nothing
End Function
It sends the http request, and will return you the contents of that url, or a 404 error. The 404 error can be replaced by an err.raise, but that's all up to you to design it the way you want it to.
regards,
CJ
Using XMLHTTP Object
Private Sub Send_HTTP_REquest
Dim DataToSend As String
Dim objXML As Object
DateToSend = "id=1"
Set objXML = CreateObject("Microsoft.XM LHTTP")
objXML.Open("POST", "http://www.domain/your_page.asp", false)
objXML.setRequestHeader "Content-Type", "application/x-www-form-ur lencoded"
objXML.send DataToSend
End Sub
More information here
http://support.microsoft.com/support/kb/articles/Q290/5/91.ASP
hongjun
Private Sub Send_HTTP_REquest
Dim DataToSend As String
Dim objXML As Object
DateToSend = "id=1"
Set objXML = CreateObject("Microsoft.XM
objXML.Open("POST", "http://www.domain/your_page.asp", false)
objXML.setRequestHeader "Content-Type", "application/x-www-form-ur
objXML.send DataToSend
End Sub
More information here
http://support.microsoft.com/support/kb/articles/Q290/5/91.ASP
hongjun
ASKER
hi hongqiun!
that xml solution works however it removes all the spaces inside my data...
for example, if i set
DateToSend = "name=Eric Ang&body=Hello World"
i would recieve "EricAng", and "HelloWorld"
Any solutions??
Thanks
that xml solution works however it removes all the spaces inside my data...
for example, if i set
DateToSend = "name=Eric Ang&body=Hello World"
i would recieve "EricAng", and "HelloWorld"
Any solutions??
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hey Man! You are great!!
Thanks a million!
Thanks a million!
I am still learning like everyone here.
hongjun
hongjun
inet1.Execute "http://website.com/page.asp", "POST", "TEST=TEST"