Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

http post help

Status
Not open for further replies.

aco636

IS-IT--Management
Nov 25, 2003
212
GB
Hi there

As always, any help gratefully received.

I know virtually nothing about http post. however, I need to knock a script up that allows me to pass data to a URL in the form of


I can crate the url no problem but domt understand how to pass the data. I have searched the cant find much material/examples. I have seen a very short function using microsoft.xmlhttp object but dont understand how to use it. Have also seen an example using a non visable instance of IE

Any help/examples gratefully received.

Regards ACO
 
What is the use of posting data? Why are those lines seem broken? From where to post? By what to receive response? It is not the script that's important. It is often the formulation of the problem or the need that's important.
 
Hi there

The url I posted is not correct, it should read
Code:
[URL unfurl="true"]http://username:password@members.somedomain.com/services/stealthmode.php?monitor=ab12aaa&mode=on[/URL]

I have been tryining with the following code.. However, I have no way of getting a sucess/fail from the post. So as far as I am concerned, my code appears to work. However, I dont think it is working correctly.

THe idea is when the post is made, it hides specific data from view in a web portal. I can still see the data regardless.

This has been pinched from two web sites MSDN & I cant recall the otehr site. Found with Google using search "vbScript HTTP Post"
Code:
sUrl = "[URL unfurl="true"]http://kings01:oliver06@members.fleetview.co.uk/services/stealthmode.php"[/URL]
sRequest = "vehicle=" & sVreg & Chr(38) & "mode=" & sMode

HTTPPost sUrl, sRequest

Function HTTPPost(sUrl, sRequest)
  set oHTTP = CreateObject("Microsoft.XMLHTTP")
  oHTTP.open "POST", sUrl,false
  oHTTP.setRequestHeader "Content-Type", "application/x-[URL unfurl="true"]www-form-urlencoded"[/URL]
  oHTTP.setRequestHeader "Content-Length", Len(sRequest)
  oHTTP.send sRequest
  HTTPPost = oHTTP.responseText
 End Function
 
>So as far as I am concerned, my code appears to work. However, I dont think it is working correctly.
Meaning?

If you want to set out the url appearing in the address bar as you shown, it is get method rather than post method. Try change to this.
[tt]
Function HTTPPost(sUrl, sRequest)
set oHTTP = CreateObject("Microsoft.XMLHTTP")
oHTTP.open "Get", sUrl & "?" & sRequest ,false
oHTTP.setRequestHeader "Content-Type", "application/x- oHTTP.send
HTTPPost = oHTTP.responseText
End Function
[/tt]
 
Hi there

Apologies for length of time to respond. THanks for your earlier advice.

Since trying the GET method you suggested, I now receive an error;
Errors: -2147467259 - msxml3.dll - Unspecified error

Have looked for error via Google but no joy.
I am confused about the POST and GET method, if I want to send the data it makes sense that I POST and if I want to retrieve data I want to GET?

Does this mean that when I request (GET) the url, the server runs the appropriate action? I am now very confused about the POST method.

Regards ACO
 
Hi there

I finally understand, thanks for your help. However, inthe end I got some help from a developer and found two things,

Firsly the php did not let me pass the username and passord at the front of the url so the service provider altered it so I could pass them as parameters.

Second there is a differnce between the two methods below in the way you pass paraamters. Once I found that out I just played until it worked.
set oHTTP = CreateObject("Microsoft.XMLHTTP")
Set oHTTP = CreateObject("MSXML2.ServerXMLHTTP")

Regards ACO
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top