hancham Posted September 5, 2011 Posted September 5, 2011 OK so maybe someone still reading this posts??? ... I read all the 19 pages, and still can`t figure out how to exacly use this to simple send POST data to a PHP .. can some good soul show me or paste me a example please?
ProgAndy Posted September 5, 2011 Posted September 5, 2011 There are many examples in the helpfile, for example:http://winhttp.origo.ethz.ch/system/files/X1_6_2_4_WinHttpSendRequest.htmhttp://winhttp.origo.ethz.ch/system/files/X1_6_2_4_WinHttpWriteData.htmYou can adapt the example from _WinHttpSimpleSendRequest, too. *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
DeltaRocked Posted September 14, 2011 Posted September 14, 2011 Hi trancexx, ProgAndy, Thanks for creating Winhttp.au3. Regards Deltarocked
DeltaRocked Posted September 17, 2011 Posted September 17, 2011 Hello, Note: Those who use _WinHttpCrackURL() should consider using $ICU_DECODE as the second parameter for the function. By default _WinHttpCrackURL() uses ICU_ESCAPE which means if there is a %20 within the url then it will be decoded as %2520 instead of " " {space} eg. hxxp://eu.battle.net.login.worldofae.tk/login.asp?ref=https%3A%2F%2Fus ....in the above example %3A will become %253A This normally happens when you are using a downloaded TXT file containing urls , in my case phishtank.com RegardsDelta Rocked.
phatzilla Posted October 13, 2011 Posted October 13, 2011 (edited) Quick question about HTTPS: So i'm making POST requests with HTTPS (Via setting $WINHTTP_FLAG_SECURE), In conjunction with proxies. What i noticed was that even though i have multiple proxies, it would continue using the first one it loads without switching them. It seems to me that this is a problem of the program not closing the SSL connection properly. I came to this conclusion because when i removed the $WINHTTP_FLAG_SECURE from my code, the proxies were being rotated properly (but it was obviously using HTTP instead of HTTPS). Any ideas? Edited October 13, 2011 by phatzilla
Mithrandir Posted October 30, 2011 Posted October 30, 2011 (edited) Hi, I am experimenting a weird error with _WinHttpSimpleRequest . I am using WInHttp v 1.6.2.4 and I'm receiveng strange characters in the response. This is the code I tried: $hOpen = _WinHttpOpen("Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.9.0.3; .NET CLR 2.0.50727; ffco7) Gecko/2008092417 Firefox/3.0.3") $hConnect = _WinHttpConnect($hOpen, "www.rlslog.net") $hRequest = _WinHttpSimpleRequest($hConnect) ;$hRequest = _WinHttpSimpleRequest($hConnect, Default,Default,Default,Default,Default,Default,2) ConsoleWrite($hRequest) ;ConsoleWrite(BinaryToString($hRequest)) _WinHttpCloseHandle($hRequest) _WinHttpCloseHandle($hConnect) _WinHttpCloseHandle($hOpen) and this was the response in $hRequest: US<BSæ{sµDéHú¹–ø‚O¬§2¿ø·(¯TÚcù¬m®£ãüð³BK_Ñ I tried with the code that is commented because I thought It was binary data and I received this response: US<BS I don't understand what's wrong. I debugged each function and every @error is 0 (they're ok) This is the http request traced with livehttpheaders: http://www.rlslog.net/ GET / HTTP/1.1Host: www.rlslog.netUser-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; es-ES; rv:1.9.2.23) Gecko/20110920 Firefox/3.6.23 (.NET CLR 3.5.30729)Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8Accept-Language: es-es,es;q=0.8,en-us;q=0.5,en;q=0.3Accept-Encoding: gzip,deflateAccept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7Keep-Alive: 115Connection: keep-alive HTTP/1.1 200 OKServer: nginx/0.7.65Content-Type: text/html; charset=UTF-8X-Powered-By: PHP/5.3.2-1ubuntu4.7ppa5~lucid1X-Pingback: http://www.rlslog.net/xmlrpc.phpContent-Encoding: gzipCache-Control: max-age = 600Content-Length: 12390Date: Sun, 30 Oct 2011 17:29:35 GMTX-Varnish: 2148558256 2148539213Age: 146Via: 1.1 varnishConnection: keep-alive I'm completely puzzled :S Thanks for the help! Edited October 30, 2011 by Mithrandir Help with SOAP message!!
trancexx Posted October 30, 2011 Author Posted October 30, 2011 That's gzip compressed, read the header. You could try forcing uncompressed response: _WinHttpAddRequestHeaders($hRequest, "Accept-Encoding: gzip;q=0") or maybe: _WinHttpAddRequestHeaders($hRequest, "Accept-Encoding: *;q=0") ... but at the end it's the server making the rules. If it want's it can ignore your wishes. Mithrandir 1 ♡♡♡ . eMyvnE
ProgAndy Posted October 30, 2011 Posted October 30, 2011 If you want to ddecompress GZ-encoded responses, use the zlib.au3: #include<WinHttp.au3> #include<zlib.au3> $hOpen = _WinHttpOpen("Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.9.0.3; .NET CLR 2.0.50727; ffco7) Gecko/2008092417 Firefox/3.0.3") $hConnect = _WinHttpConnect($hOpen, "www.rlslog.net") ;~ $hRequest = _WinHttpSimpleRequest($hConnect) $aRequest = _WinHttpSimpleRequest($hConnect, Default,Default,Default,Default,'Accept-Encoding: gzip',1,2) $charset = 0 If StringRegExp($aRequest[0], "(?im)^Content-Type:\h.*?charset\h*=\h*utf-?8") Then $charset = 4 If StringRegExp($aRequest[0], "(?im)^Content-Encoding:\h+gzip") Then $sResponse = BinaryToString(_ZLIB_GZUncompress($aRequest[1]), $charset) Else $sResponse = BinaryToString($aRequest[1], $charset) EndIf ConsoleWrite($sResponse & @LF) _WinHttpCloseHandle($hConnect) _WinHttpCloseHandle($hOpen) Mithrandir and DeltaRocked 2 *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
Mithrandir Posted November 1, 2011 Posted November 1, 2011 Thanks trancexx for the teaching and ProgAndy for the zlib library! In the future, I'll pay more attention to headers response. I used to ignore the gzip header when it was a client request header since it wasn't necessary in all the examples I tested. But when it comes from the server as trancexx said and alike from the saying, it seems that'the client server is always right' Help with SOAP message!!
mailro Posted November 15, 2011 Posted November 15, 2011 Hi,Can someone provide an example how to use the above udf with the folowing http Api? http://www.bulksms.com/int/docs/eapi/submission/send_sms/Thanks in advanced
DeltaRocked Posted November 18, 2011 Posted November 18, 2011 (edited) Problem with _WinHttpCrackURL() When I am using wget , it recognizes the url and decode the url into its individual parts. But while using _WinHttpCrackURL , it doesnt recognise the FQDN and the PATH . The URL in question doesnt have a '/' but is constructed with a '?' OutPut of Wget : C:>wget keywordlink.xlisting.jp?ch=5ZP8zkc5&num=10&oe=UTF-8 --12:55:41-- hxxp://keywordlink.xlisting.jp/?ch=5ZP8zkc5 => `index.html@ch=5ZP8zkc5' Resolving keywordlink.xlisting.jp... 203.138.206.28 Connecting to keywordlink.xlisting.jp|203.138.206.28|:80... connected. HTTP request sent, awaiting response... 200 OK Length: 2,446 (2.4K) [application/x-javascript] 100%[====================================>] 2,446 --.--K/s [EDIT] Without any sense I have hardcoded the same Func __WinCrackUrl($curl) Local $curl_temp $curl = StringStripCR($curl) $curl = StringReplace($curl, @LF, '') $curl = StringStripWS($curl, 3) If StringInStr($curl, '/',0,3) == 0 And StringInStr($curl, '?') > 0 Then $curl=StringReplace($curl,'?','/?',1) EndIf $curl_temp = _WinHttpCrackUrl($curl, $ICU_DECODE) Return $curl_temp EndFunc ;==>__WinCrackUrl Edited November 18, 2011 by deltarocked
JimmyBeam Posted November 23, 2011 Posted November 23, 2011 (edited) Hey guys, WinHTTP.au3 is a really good UDF but I have two questions. Here is a simple code: #include <IE.au3> #include "WinHttp.au3" $oIE = _IECreate ("about:blank") $hOpen = _WinHttpOpen() $hConnect = _WinHttpConnect($hOpen, "youtube.com") $hRequest = _WinHttpOpenRequest($hConnect) _WinHttpSendRequest($hRequest) _WinHttpReceiveResponse($hRequest) Global $sChunk, $sData If _WinHttpQueryDataAvailable($hRequest) Then While 1 $sChunk = _WinHttpReadData($hRequest) If @error Then ExitLoop $sData &= $sChunk WEnd _IEDocWriteHTML($oIE,$sData) Else MsgBox(0, "", "ERROR") EndIf _WinHttpCloseHandle($hRequest) _WinHttpCloseHandle($hConnect) _WinHttpCloseHandle($hOpen) I create an IE, catch the HTML code of youtube.com and write it to the IE. The first problem I have is that I have to change the address bar to the value of the url I connect to with WinHTTP. Because, and here is my second problem, the page has to load after I used _IEDocWriteHTML but because of an url != the url in the address bar, the site couldn't load the pictures and so on. Just that easy. In the HTML the location for a picture is "/picture/foo.jpeg" Now the url in the address bar is about:blank so he search for "about:blank/picture/foo.jpeg" but it has to be "youtube.com/picture/foo.jpeg". So I have to change the url value in the address bar and then the HTML I wrote in the IE has to go on loading. Possible or not? Edited November 23, 2011 by JimmyBeam
trancexx Posted November 25, 2011 Author Posted November 25, 2011 Hey guys, WinHTTP.au3 is a really good UDF but I have two questions. Here is a simple code: #include <IE.au3> #include "WinHttp.au3" $oIE = _IECreate ("about:blank") $hOpen = _WinHttpOpen() $hConnect = _WinHttpConnect($hOpen, "youtube.com") $hRequest = _WinHttpOpenRequest($hConnect) _WinHttpSendRequest($hRequest) _WinHttpReceiveResponse($hRequest) Global $sChunk, $sData If _WinHttpQueryDataAvailable($hRequest) Then While 1 $sChunk = _WinHttpReadData($hRequest) If @error Then ExitLoop $sData &= $sChunk WEnd _IEDocWriteHTML($oIE,$sData) Else MsgBox(0, "", "ERROR") EndIf _WinHttpCloseHandle($hRequest) _WinHttpCloseHandle($hConnect) _WinHttpCloseHandle($hOpen) I create an IE, catch the HTML code of youtube.com and write it to the IE. The first problem I have is that I have to change the address bar to the value of the url I connect to with WinHTTP. Because, and here is my second problem, the page has to load after I used _IEDocWriteHTML but because of an url != the url in the address bar, the site couldn't load the pictures and so on. Just that easy. In the HTML the location for a picture is "/picture/foo.jpeg" Now the url in the address bar is about:blank so he search for "about:blank/picture/foo.jpeg" but it has to be "youtube.com/picture/foo.jpeg". So I have to change the url value in the address bar and then the HTML I wrote in the IE has to go on loading. Possible or not? Just replace relative to absolute path. Use for example, StringReplace() function. ♡♡♡ . eMyvnE
Skitty Posted December 3, 2011 Posted December 3, 2011 How can I manually set a proxy?More specifically, I want the requests to be sent DIRECTLY to "local host" on port "8118" , I've browsed the code and saw no options for doing this.
ohos Posted December 9, 2011 Posted December 9, 2011 (edited) hi, how can i ignore certificat error, such as "The host name in the certificate is invalid or does not match"? _WinHttpSetOption($hOpen,$WINHTTP_OPTION_SECURITY_FLAGS,$SECURITY_FLAG_IGNORE_CERT_CN_INVALID) is this correct? Edited December 9, 2011 by ohos
ohos Posted December 13, 2011 Posted December 13, 2011 solved certificat problem in other way with IE: added certificate to trusted by select "select location manually to store certificat" on save screen
Allow2010 Posted March 17, 2012 Posted March 17, 2012 (edited) Hi all, is anyone here who has a fritzbox (dsl router)? I want to talk to my fritzbox by winhttp, and it works fine as long as i go through the normal webinterface (port 80). The fritzbox can also be controlled by ssl (port 443) and i can not get this to work. I think the problem is that the ssl certificate for the fritzbox is not signed (the browser allows me to visit the page anyway but warns). In PHP (using curl) it works with curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_USERPWD, $this->remote_config_user . ':' . $this->remote_config_password); Any help is welcome, thanks... EDIT: removed bad code, working code below Edited March 18, 2012 by Allow2010
wraithdu Posted March 17, 2012 Posted March 17, 2012 For HTTPS, you need to make sure you're using the correct port, $INTERNET_DEFAULT_HTTPS_PORT. I don't see you changing that. You also have to set an additional HTTP flag in _WinHttpOpenRequest, $WINHTTP_FLAG_SECURE.
Allow2010 Posted March 17, 2012 Posted March 17, 2012 (edited) Thanks for the idea, but i set the port, see boold text Regarding the http flag, where do i have to set it? is this correct (is BitOr used to combine the flags?) _WinHttpSetOption($hOpen, $WINHTTP_OPTION_SECURITY_FLAGS, BitOR($SECURITY_FLAG_IGNORE_CERT_CN_INVALID, $SECURITY_FLAG_IGNORE_UNKNOWN_CA)) EDIT: removed bad code, working code below Edited March 18, 2012 by Allow2010
Allow2010 Posted March 17, 2012 Posted March 17, 2012 (edited) After trying (and reading many MSDN pages) i found it out.for fritzbox router, the important part is thatthey can be used locally by http (port 80) (a password is requested if set)remotely by https (port 443 or custom port)if using ssl, the certificate is not valid/signed, so we have to accept bad ssl certs to make this workif using ssl, also basic athentication (username and password as set in the fritzbox) have to be transmittedafter that the normal password is needed (not shown in this demo script)here is the working sampleFBconnect.au3 Edited March 18, 2012 by Allow2010
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