Luigi Posted March 18, 2017 Share Posted March 18, 2017 (edited) Greetings! I have a little AutoIt script and try authenticate in my PHP aplication, like this: Global $oHTTP = ObjCreate("WinHttp.WinHttpRequest.5.1") Global $REMOTE_URL = "http://localhost/index.php" Global $REMOTE_USER = "user", $REMOTE_PASS = "pass" Func Post($func = "") $oHTTP.Open("POST", $REMOTE_URL, False) ;~ dXNlcjpwYXNz = base64( "user:pass" ) $oHTTP.SetRequestHeader("Authorization", "Basic dXNlcjpwYXNz") $oHTTP.SetCredentials($REMOTE_USER, $REMOTE_PASS, 0) $oHTTP.Send($func) $oHTTP.WaitForResponse() Local $oAllHeaders = $oHTTP.GetAllResponseHeaders() ConsoleWrite("+HEADERS=================================" & @LF) ConsoleWrite($oAllHeaders & @LF) ConsoleWrite("-HEADERS=================================" & @LF) Local $oo = $oHTTP.ResponseText ConsoleWrite("+RESPONSE================================" & @LF) ConsoleWrite($oo & @LF) ConsoleWrite("-RESPONSE================================" & @LF) EndFunc My PHP is... <?php if( isset( $_SERVER['PHP_AUTH_USER'] ) ){ echo "user[ {$_SERVER['PHP_AUTH_USER']} ]\n"; }else{ echo "user[ not exist ]\n"; } if( isset( $_SERVER['PHP_AUTH_PW'] ) ){ echo "pass[ {$_SERVER['PHP_AUTH_PW']} ]\n"; }else{ echo "pass[ not exist ]\n"; } ?> If I use $oHTTP.SetCredentials($REMOTE_USER, $REMOTE_PASS, 0) none user/pass is found. If I use $oHTTP.SetRequestHeader("Authorization", "Basic dXNlcjpwYXNz"), I have user/pass. I thought that SetCredentials turned the user/pass into Autorizathion Basic dXNlcjpwYXNz, but I see that it does not. I see that SetCredentials is not seen by PHP. Where is my error? Is it possible to do that? Notes:Internet Explorer does not support user names and passwords in Web site addresses (HTTP or HTTPS URLs). Best regards Edited March 18, 2017 by Luigi Visit my repository Link to comment Share on other sites More sharing options...
Jasp402 Posted December 15, 2017 Share Posted December 15, 2017 Your code not work with port diferent. for example I have port 6448. and not Work. Say Error: $oHTTP.Send() $oHTTP^ ERROR 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