eson Posted October 12, 2010 Share Posted October 12, 2010 Hello, I tryed not to post but I could not find the reason my short script is not working. I'm trying to fill and submit a very simple form (secure) but the result I get is the same form page I started with, not the expected result page (as after pressing the submit button). Could you help me, please? My script: #AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 #include "WinHttp.au3" Opt("MustDeclareVars", 1) ; !!!Note that this example will fail because of invalid username and password!!! ; Use real data for authentication Global $sUserName = "12345678909" Global $sPassword = "11111970" Global $sDomain = "ccd.serpro.gov.br" Global $sPage = "correios/acecpfa1/solicitar.html" Global $sAdditionalData = "cpF=" & $sUserName & "&nasC=" & $sPassword ; Initialize and get session handle Global $hOpen = _WinHttpOpen() ; Get connection handle Global $hConnect = _WinHttpConnect($hOpen, $sDomain) ; SimpleSSL-request it... Global $sReturned = _WinHttpSimpleSSLRequest($hConnect, "POST", $sPage, Default, $sAdditionalData) ; Close handles _WinHttpCloseHandle($hConnect) _WinHttpCloseHandle($hOpen) ; See what's returned MsgBox(0, "Returned", $sReturned) Link to comment Share on other sites More sharing options...
marko001 Posted October 12, 2010 Share Posted October 12, 2010 @trancexx _WinHttpCloseHandle($hConnect) _WinHttpCloseHandle($hOpen) ... $hOpen2 = _WinHttpOpen() $hConnect = _WinHttpConnect($hOpen2, $sAddress) _WinHttpSetOption($hOpen2, $WINHTTP_OPTION_DISABLE_FEATURE, $WINHTTP_DISABLE_COOKIES) Yes I already closed it and reopened in new Handle. End result is the 1st file correctly filled (over 70kb) and I get there the ID ($p_Id)I need to get the 2nd URL. Once i concatenate datas $spage_2= $spage_2& $p_id I get the full URL ($address + $page_2) but when I process the POST request it ends as before also adding the string you suggested me. Still 0 Bytes file... Any hint? Ty mate, M. Link to comment Share on other sites More sharing options...
trancexx Posted October 12, 2010 Author Share Posted October 12, 2010 Yes I already closed it and reopened in new Handle. Well, don't close $hOpen if you want to keep cookies. That handle have cookies. WinHttpCloseHandle($hConnect) ;_WinHttpCloseHandle($hOpen) ... ;$hOpen2 = _WinHttpOpen() $hConnect = _WinHttpConnect($hOpen, $sAddress)) ; the same $hOpen @eson, ccd.serpro.gov.br/correios/acecpfa1/solicitar.html doesn't exist. ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
marko001 Posted October 12, 2010 Share Posted October 12, 2010 (edited) Same result, 0 byte file. I'll PVT you the original file with all my datas, so you can check yourself. Forget about ";" and comments, it's just to test all the steps, but you will surely understand it well. M. Edited October 12, 2010 by marko001 Link to comment Share on other sites More sharing options...
trancexx Posted October 12, 2010 Author Share Posted October 12, 2010 Same result, 0 byte file. I'll PVT you the original file with all my datas, so you can check yourself.Forget about ";" and comments, it's just to test all the steps, but you will surely understand it well.M.Your message was cut-off in the middle. I only got few lines of code. But to make one thing clear if it's not; Ask for help with code, don't ask for code. Your script must be runnable, I have no intention of fixing trivialities. ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
marko001 Posted October 12, 2010 Share Posted October 12, 2010 Agreed, it's my intention to self-develop it, I personally think i can manage the code, I just miss some datas as I stated before. I sent you the code working with my credentials, you can take a look and you can also post the solution (I think useful for the community) here. Thanks again, Marco Link to comment Share on other sites More sharing options...
spymare Posted October 17, 2010 Share Posted October 17, 2010 (edited) how would i make a script using winhttp to upload a file with a form like this: www.dbq.dk Edited October 17, 2010 by spymare Link to comment Share on other sites More sharing options...
hench Posted October 27, 2010 Share Posted October 27, 2010 yo trancexx, prog@ndy !!i've been reading entirely this thread 2-3 timeswhile trying on a piece of project using this wonderful WinHTTP UDF, I finally arrived to some result !!and wanted to tell you that you guys rock !!!! I'm learning a lot through your pieces of code, examples, and UDF.thats itcheers!hench Link to comment Share on other sites More sharing options...
trancexx Posted October 28, 2010 Author Share Posted October 28, 2010 yo trancexx, prog@ndy !!i've been reading entirely this thread 2-3 timeswhile trying on a piece of project using this wonderful WinHTTP UDF, I finally arrived to some result !!and wanted to tell you that you guys rock !!!! I'm learning a lot through your pieces of code, examples, and UDF.thats itcheers!hench okely-dokely Just remember that recycling cans is important ...and other stuff like that. Go now and make us all proud. SupaNewb 1 ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
Brejack Posted November 8, 2010 Share Posted November 8, 2010 I need same help.. I have to send the url above. This send a command to a openfire internal server to add an account. I'm trying with _WinHttpSimpleSendSSLRequest, but it doesn't working... URL: "https://10.6.0.67:9091/plugins/userService/userservice?type=add&secret=7Kfs4nj3&username=teste&password=drowssap&name=franz&email=franz@kafka.com" thanks brejack Link to comment Share on other sites More sharing options...
trancexx Posted November 8, 2010 Author Share Posted November 8, 2010 That's on port 9091. You need to specify that. ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
Brejack Posted November 11, 2010 Share Posted November 11, 2010 That's on port 9091. You need to specify that.Sorry, but it its not working fine...Can you post the code for me, that send the url above?"https://10.6.0.67:9091/plugins/userService/userservice?type=add&secret=7Kfs4nj3&username=teste&password=drowssap&name=franz&email=franz@kafka.com" Thanks for help!! Link to comment Share on other sites More sharing options...
JohnOne Posted November 11, 2010 Share Posted November 11, 2010 Yes trancexx, and hurry up about it. Brejack has'nt got all day you know. SupaNewb 1 AutoIt Absolute Beginners  Require a serial  Pause Script  Video Tutorials by Morthawt  ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
cypher175 Posted November 11, 2010 Share Posted November 11, 2010 Does anyone have an example of how to use this UDF to get the HTML or TEXT from a webpage that requires basic login credentials to access it..? Link to comment Share on other sites More sharing options...
ProgAndy Posted November 11, 2010 Share Posted November 11, 2010 Does anyone have an example of how to use this UDF to get the HTML or TEXT from a webpage that requires basic login credentials to access it..?Just open the helpfile and read the entry for _WinHttpSetCredentials? *GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes Link to comment Share on other sites More sharing options...
cypher175 Posted November 13, 2010 Share Posted November 13, 2010 (edited) Is there any way to Change or Disable Keep-Alive Connections at all when using functions from this UDF..?? I googled for countless hours and came across these articles, but im not quite sure how to implement them into this UDF though..?? http://social.msdn.microsoft.com/Forums/en/vclanguage/thread/fb120cfe-bfae-400b-8675-74444f1910a5 http://www.geekpedia.com/Thread28023_Disabling-Keep-alive.html Edited November 13, 2010 by cypher175 Link to comment Share on other sites More sharing options...
trancexx Posted November 13, 2010 Author Share Posted November 13, 2010 (edited) Is there any way to Change or Disable Keep-Alive Connections at all when using functions from this UDF..?? I googled for countless hours and came across these articles, but im not quite sure how to implement them into this UDF though..?? http://social.msdn.microsoft.com/Forums/en/vclanguage/thread/fb120cfe-bfae-400b-8675-74444f1910a5 http://www.geekpedia.com/Thread28023_Disabling-Keep-alive.html I don't see a problem with that. This works just fine for me (modified _WinHttpReadData.au3): expandcollapse popup#AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 #include "WinHttp.au3" Opt("MustDeclareVars", 1) ; Initialize Global $hOpen = _WinHttpOpen() If @error Then MsgBox(48, "Error", "Error initializing the usage of WinHTTP functions.") Exit 1 EndIf ; Specify what to connect to Global $hConnect = _WinHttpConnect($hOpen, "yahoo.com") ; <- yours here If @error Then MsgBox(48, "Error", "Error specifying the initial target server of an HTTP request.") _WinHttpCloseHandle($hOpen) Exit 2 EndIf ; Create request Global $hRequest = _WinHttpOpenRequest($hConnect) If @error Then MsgBox(48, "Error", "Error creating an HTTP request handle.") _WinHttpCloseHandle($hConnect) _WinHttpCloseHandle($hOpen) Exit 3 EndIf ;======================================================================================= If _WinHttpSetOption($hRequest, $WINHTTP_OPTION_DISABLE_FEATURE, $WINHTTP_DISABLE_KEEP_ALIVE) Then MsgBox(64, "Yes!", "Sucessfully modified KEEP_ALIVE feature.") Else MsgBox(64, "Shit", "Something went wrong. Ah well...") EndIf ;======================================================================================= ; Send it _WinHttpSendRequest($hRequest) If @error Then MsgBox(48, "Error", "Error sending specified request.") _WinHttpCloseHandle($hConnect) _WinHttpCloseHandle($hOpen) Exit 4 EndIf ; Wait for the response _WinHttpReceiveResponse($hRequest) ; See if there is data to read Global $sChunk, $sData If _WinHttpQueryDataAvailable($hRequest) Then ; Read While 1 $sChunk = _WinHttpReadData($hRequest) If @error Then ExitLoop $sData &= $sChunk WEnd ConsoleWrite($sData & @CRLF) ; print to console Else MsgBox(48, "Error", "Site is experiencing problems.") EndIf ; Close handles when they are not needed any more _WinHttpCloseHandle($hRequest) _WinHttpCloseHandle($hConnect) _WinHttpCloseHandle($hOpen) You? edit: the result will be "Connection: Close" I guess it can be done like this too: _WinHttpAddRequestHeaders($hRequest, "Connection: Close", $WINHTTP_ADDREQ_FLAG_ADD) So, I really don't see a problem. But of course I could be misunderstanding what you want to do. Edited November 13, 2010 by trancexx ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
cypher175 Posted November 14, 2010 Share Posted November 14, 2010 wow thanks, I cant believe it was just a simple "Connection: Close" that I needed to use for the $sHeader option with "_WinHttpSimpleRequest()" to disable "Keep-Alives"... So when using the "_WinHttpSimpleRequest()" function, how do you send more than one - Additional Headers Values for $sHeader..?? Also, How can I Specify a "Keep-Alive-Time-Out-Value" for the $sHeader Option..?? Link to comment Share on other sites More sharing options...
trancexx Posted November 14, 2010 Author Share Posted November 14, 2010 (edited) So when using the "_WinHttpSimpleRequest()" function, how do you send more than one - Additional Headers Values for $sHeader..?? Separate them with @CRLF: "Connection: Close" & @CRLF & "Referrer: something" & @CRLF & ... Also, How can I Specify a "Keep-Alive-Time-Out-Value" for the $sHeader Option..?? Same thing: "Keep-Alive: timeout=15" edit: why do you use so much question marks? To express emotion or what? ??? Edited November 14, 2010 by trancexx ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
cypher175 Posted November 28, 2010 Share Posted November 28, 2010 is there anyway to share a cookie from a login amung multiple au3.exe processes using these HTTP UDF functions..? 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