Search the Community
Showing results for tags 'winhttp utf-8 unicode post php'.
-
Hi everyone! I'm trying to send a string (Filename in Arabic) as a post parameter to PHP using the WinHttp UDF. The problem i'm facing is that, at the server end, the string shows up as "Question Marks" and not in Arabic. However, if i send this string using the Winhttp Objects, it shows up properly in Arabic. Is there any setting in the WinHttp UDF that i need to set before sending the post request, something that would send the post parameter as a UTF-8 string? The request being sent is over SSL, and im using the _WinHttpSimpleSendSSLRequest function. here's the code im using. #NoTrayIcon #include<Winhttp.au3> $domain = "someserver.com" $sPath = "/utf-echo.php" Global $ua = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/12.10240" $utfText = "مرحبا بالعالم.docx" $postData = "utf=" & $utfText ;Using Winhttp Object _httpRequestObj("https://" & $domain & $sPath ,'POST', $postData, $ua) ;Using Winhttp UDF $hOpen = _WinHttpOpen($ua) $hConnect = _WinHttpConnect($hOpen, $domain) $hRequest = _WinHttpSimpleSendSSLRequest($hConnect, "POST", $sPath, Default, $postData, Default) Func _httpRequestObj($url, $method, $postData, $ua) $oHTTP = ObjCreate('WinHTTP.WinHTTPRequest.5.1') $method = StringLower($method) Local $oHTTP = ObjCreate('WinHttp.WinHttpRequest.5.1') $oHTTP.Open($method, $url, False) $oHTTP.SetRequestHeader('User-Agent', $ua) $oHTTP.Option(4) = 13056 $oHTTP.Option(9) = 168 If $method = 'GET' Then $oHTTP.Send() Else $oHTTP.SetRequestHeader('Content-Type', 'application/x-www-form-urlencoded') $oHTTP.SetRequestHeader('Content-Length', StringLen($postData)) $oHTTP.Send($postData) EndIf $oHTTP.WaitForResponse Local $ret[2] $ret["0"] = $oHTTP.Status $ret["1"] = $oHTTP.Responsetext Return $ret EndFunc ;==>_ProxyhttpRequest Output at the server end: Hope this explains the situation! Any help would be appreciated! thanks!!