I'm making a darkorbit bot and I came across this problem:
I call the function and this problem appears: "$ auth_session_location = $ http.GetResponseHeader ('Location')
$ Auth_session_location = $ http ^ ERROR "
I call it like this:
Local $a = __darkorbit_login($rUsername, $rPassword, 'http://www.darkorbit.com')
If $a == 0 Then
MsgBox(48, 'Login Failed', 'Chould not login')
Else
__darkorbit_load_game($a)
EndIf
If $a == 0 Then
MsgBox(48, 'Login Failed', 'Chould not login')
Else
__darkorbit_load_game($a)
EndIf
Are the functions:
Func __darkorbit_load_game($url)
RunWait('RunDLL32.exe InetCpl.cpl, ClearMyTracksByProcess 255')
$browser.navigate($url)
$browser = 0
EndFunc ;==>__darkorbit_load_game
Func __darkorbit_login($u, $p, $l)
$http = ObjCreate('winhttp.winhttprequest.5.1') ;open winhttp COM
$http.open('GET', $l) ;opens a connection to darkorbit.com
$http.send() ;sends request
$http.WaitForResponse(5000) ;waits maximum of 5 seconds for return
$www_darkorbit_response = $http.ResponseText() ;gets the html source code of darkorbit.com
$auth_bpsecure_token = _StringBetween($www_darkorbit_response, 'class="bgcdw_login_form" action="', '">') ;reads the bpsecure token
$auth_bpsecure_token = StringTrimLeft($auth_bpsecure_token[0], StringInStr($auth_bpsecure_token[0], '')) ;trims token from array to regular string
$auth_bpsecure_token = StringReplace($auth_bpsecure_token, '&', '&') ;replace & with & symbol
$http.open('POST', $auth_bpsecure_token) ;opens a POST connection to bpsecure with token url
$http.SetRequestHeader('Content-Type', 'application/x-www-form-urlencoded') ;set request header
$net_post_login = 'username=' & _Encode($u) & '&password=' & $p ;packet format for username and password. username must be encoded to support special char
$http.send($net_post_login) ;sends request
$http.WaitForResponse(5000) ;waits maximum of 5 seconds for return
$auth_session_location = $http.GetResponseHeader('Location') ;gets ProjectApi authorization user and token
$http.open('GET', $auth_session_location) ;opens connection with new token url
$http.send() ;sends request
$http.WaitForResponse(5000) ;waits maximum of 5 seconds for return
$http_response_auth = $http.ResponseBody() ;gets html source in binary
$bin2string_auth = BinaryToString($http_response_auth) ;converts to string
$auth_cookie = $http.GetResponseHeader('Set-Cookie') ;reads cookie headers
$auth_bpsecure_sid = _StringBetween($auth_cookie, 'dosid=', '; path=/') ;gets dosid (session id)
$auth_bpsecure_sid = StringTrimLeft($auth_bpsecure_sid[0], StringInStr($auth_bpsecure_sid[0], '')) ;trims sid from array to regular string
$user_darkorbit_server = _StringBetween($bin2string_auth, 'rel="meta" href="http://', '.darkorbit.bigpoint') ;reads current server. also used to see if login username and/or password are correct/incorrect
If @error Then
Return 0
EndIf
If $user_darkorbit_server[0] == 0 Then ;checks if array is equar to 0 (no server was found)
Return 0
EndIf
$http = 0 ;closes connection
Return 'http://' & $user_darkorbit_server[0] & '.darkorbit.bigpoint.com/indexInternal.es?action=internalMapRevolution&dosi d=' & $auth_bpsecure_sid ;complete link
EndFunc ;==>__darkorbit_login
Func _Encode($string) ;username encoding function
$UBinary = StringToBinary($string, 4)
$UBinary2 = StringReplace($UBinary, '0x', '', 1)
$UBinaryLength = StringLen($UBinary2)
Local $encoded
For $i = 1 To $UBinaryLength Step 2
$UBinaryChar = StringMid($UBinary2, $i, 2)
If StringInStr("", BinaryToString('0x' & $UBinaryChar, 4)) Then
$encoded &= BinaryToString('0x' & $UBinaryChar)
Else
$encoded &= '%' & $UBinaryChar
EndIf
Next
Return $encoded
EndFunc ;==>_Encode
RunWait('RunDLL32.exe InetCpl.cpl, ClearMyTracksByProcess 255')
$browser.navigate($url)
$browser = 0
EndFunc ;==>__darkorbit_load_game
Func __darkorbit_login($u, $p, $l)
$http = ObjCreate('winhttp.winhttprequest.5.1') ;open winhttp COM
$http.open('GET', $l) ;opens a connection to darkorbit.com
$http.send() ;sends request
$http.WaitForResponse(5000) ;waits maximum of 5 seconds for return
$www_darkorbit_response = $http.ResponseText() ;gets the html source code of darkorbit.com
$auth_bpsecure_token = _StringBetween($www_darkorbit_response, 'class="bgcdw_login_form" action="', '">') ;reads the bpsecure token
$auth_bpsecure_token = StringTrimLeft($auth_bpsecure_token[0], StringInStr($auth_bpsecure_token[0], '')) ;trims token from array to regular string
$auth_bpsecure_token = StringReplace($auth_bpsecure_token, '&', '&') ;replace & with & symbol
$http.open('POST', $auth_bpsecure_token) ;opens a POST connection to bpsecure with token url
$http.SetRequestHeader('Content-Type', 'application/x-www-form-urlencoded') ;set request header
$net_post_login = 'username=' & _Encode($u) & '&password=' & $p ;packet format for username and password. username must be encoded to support special char
$http.send($net_post_login) ;sends request
$http.WaitForResponse(5000) ;waits maximum of 5 seconds for return
$auth_session_location = $http.GetResponseHeader('Location') ;gets ProjectApi authorization user and token
$http.open('GET', $auth_session_location) ;opens connection with new token url
$http.send() ;sends request
$http.WaitForResponse(5000) ;waits maximum of 5 seconds for return
$http_response_auth = $http.ResponseBody() ;gets html source in binary
$bin2string_auth = BinaryToString($http_response_auth) ;converts to string
$auth_cookie = $http.GetResponseHeader('Set-Cookie') ;reads cookie headers
$auth_bpsecure_sid = _StringBetween($auth_cookie, 'dosid=', '; path=/') ;gets dosid (session id)
$auth_bpsecure_sid = StringTrimLeft($auth_bpsecure_sid[0], StringInStr($auth_bpsecure_sid[0], '')) ;trims sid from array to regular string
$user_darkorbit_server = _StringBetween($bin2string_auth, 'rel="meta" href="http://', '.darkorbit.bigpoint') ;reads current server. also used to see if login username and/or password are correct/incorrect
If @error Then
Return 0
EndIf
If $user_darkorbit_server[0] == 0 Then ;checks if array is equar to 0 (no server was found)
Return 0
EndIf
$http = 0 ;closes connection
Return 'http://' & $user_darkorbit_server[0] & '.darkorbit.bigpoint.com/indexInternal.es?action=internalMapRevolution&dosi d=' & $auth_bpsecure_sid ;complete link
EndFunc ;==>__darkorbit_login
Func _Encode($string) ;username encoding function
$UBinary = StringToBinary($string, 4)
$UBinary2 = StringReplace($UBinary, '0x', '', 1)
$UBinaryLength = StringLen($UBinary2)
Local $encoded
For $i = 1 To $UBinaryLength Step 2
$UBinaryChar = StringMid($UBinary2, $i, 2)
If StringInStr("", BinaryToString('0x' & $UBinaryChar, 4)) Then
$encoded &= BinaryToString('0x' & $UBinaryChar)
Else
$encoded &= '%' & $UBinaryChar
EndIf
Next
Return $encoded
EndFunc ;==>_Encode






