StAbb Posted October 14, 2008 Share Posted October 14, 2008 Hey guys,I recently used the example here: http://www.autoitscript.com/forum/index.php?showtopic=30342 in an attemp to send a post request. I used the first exmaple which uses OverloadUT's HTTP UDF here: http://www.autoitscript.com/forum/index.ph...mp;#entry319354.I made an example page at www.sabbgrafix.com/welcome.php which is an extremely simple post example. I use an ISSET function to display post information, if there is any submitted. The post info is "name=yourNameHere". I used the following code, but when I try and return the body of the page after the post request is sent, I get nothing. But the @error is 0 and the other attributes state that it sucesfully connected and sent. #include <IE.au3> #include <http.au3> $Header = "Content-Type: application/x-www-form-urlencoded" $Host = "www.sabbgrafix.com" $File = "/welcome.php" $URL = "http://" & $Host & $File $PostData = "name=steve" $Socket = _HTTPConnect($Host) _HTTPPost($Host, $File, $Socket, $PostData) $recv = _HTTPRead($Socket,0) MsgBox(0,"","BODY: "&$recv&" ERROR: "&@error) _HTTPClose($Socket)Any ideas as to what I'm doing wrong, or anyone know of any other more efficient ways to send POST requests to sites via AutoIt?Thanks guys!-Steve Link to comment Share on other sites More sharing options...
j0linus Posted October 15, 2008 Share Posted October 15, 2008 I have tested your example with Firefox and LiveHttpHeader extension. The response is:HTTP/1.x 200 OKConnection: closeDate: Wed, 15 Oct 2008 04:21:31 GMTServer: Microsoft-IIS/6.0X-Powered-By: ASP.NET, PHP/4.3.11Content-Type: text/htmlI think the HTTP UDF doesn't work because there is no Content-Length value in the response and when i look at the html code it is the same like before the POST.(checked with IE and it works - contains new html code after the POST)I think the easiest way to send post request is to use IE UDF (_IEFormElementSetValue, _IEFormSubmit and so on).It depends on what you want to do. The WinInet functions MSDN or Ultima UDF provide the most efficient way, but they are heavy the handle. The HTTP UDF is the best middle way the work with HTTP Headers, HTML code and there's no need to cookies or downloading binary files. (although with some modify it should be possible too) Link to comment Share on other sites More sharing options...
StAbb Posted October 15, 2008 Author Share Posted October 15, 2008 Thank you so much j0linus! I appreciate all your help! I knew about the _IE UDF but I was just curious as to any other ways of doing it. Thank you so much though. That cleared a lot up. -Steve Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now