Jump to content

Windows xp - Windows 7


Recommended Posts

We have the code :

#include <Winhttp.au3>

Global $HTTP = ObjCreate("winhttp.winhttprequest.5.1")

Func _HTTPRequest($HTTP, $Method, $URL, $data = "", $Return = "", $Cookie = "")
$HTTP.Open($Method, $URL, False)
If $Method = "POST" Then $HTTP.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded")
If $Cookie <> "" Then $HTTP.SetRequestHeader("Cookie", $Cookie)
$HTTP.SetRequestHeader('Accept', 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8')
$HTTP.SetRequestHeader('User-Agent', 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv: Gecko/20100625 Firefox/3.6.6')
$HTTP.SetRequestHeader("Referer", "http://m.me.zing.vn/login")
$HTTP.SetRequestHeader("Connection", "keep-alive")
$HTTP.SetRequestHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8")
$HTTP.SetRequestHeader("Accept-Language", "en-us,en;q=0.5")
$HTTP.SetRequestHeader("Accept-Charset", "ISO-8859-1,utf-8;q=0.7,*;q=0.7")
$HTTP.SetRequestHeader("Keep-Alive", "115")
Switch $Return
Case 1
Return $HTTP.Responsetext
Case 2
Return $HTTP.ResponseBody
Case 3
Return $HTTP.Getallresponseheaders & $HTTP.Responsetext
Case 4
Return $HTTP.Getallresponseheaders & $HTTP.Responsebody
EndFunc   ;==>_HTTPRequest
$id = "autoit123456"
$pw = "123456"
$data = _HTTPRequest($HTTP, "POST", "https://sso2.zing.vn/index.php?method=login", "http://sso2.zing.vn/index.php?method=login&pid=25&u1=http%3A%2F%2Flogin.me.zing.vn%2Flogin%2Fsuccess%3Furl%3Dhttp%3A%2F%2Fme.zing.vn&fp=http%3A%2F%2Flogin.me.zing.vn%2Flogin%2Ffail%3Furl%3Dhttp%3A%2F%2Fme.zing.vn&u=" & $id & "&p=" & $pw, 3)
MsgBox(0, "", $data)

When run this code on Windows xp then I obtained cookie of header, but when run one on Windows 7 then error:

The requested action with this object has failed.

Why? Who can help me?

Edited by chemthan
Link to comment
Share on other sites

I don't know if it's related with your problem, but I get the same error using the latest beta version with an object created by PacketX.

While if I switch to autoit official version, with the same code, it works well.

Try to see if the autoit versions in the two pc are the same, official non beta.

Link to comment
Share on other sites

This is what I use to retrieve a string from a PHP server with a JSON query and it works well in W7:

Local $hInternetOpen, $hInternetConnect, $hHttpOpenRequest, $hHttpSendRequest
$url = YOUR URL


        If _WinINet_InternetAttemptConnect() Then

            $hInternetOpen = _WinINet_InternetOpen("Mozilla/5.0 Firefox/3.0.1", $INTERNET_OPEN_TYPE_DIRECT, 0, Default, Default)

            $hInternetConnect = _WinINet_InternetConnect($hInternetOpen, $INTERNET_SERVICE_HTTP, "YOUR SERVER.com", 0, 0, Default, Default, 0)

            $type = "Content-Type: application/x-www-form-urlencoded" & @CRLF
            $agent = "User-Agent: Mozilla/5.0b" & @CRLF
            $toSend =  $type & $agent
            Local $hHttpOpenRequest = _WinINet_HttpOpenRequest($hInternetConnect, "POST", $url)
            $toSend &=  'Content-Length: ' & StringLen($JSONdata)
                local $hHttpSendRequest= _WinINet_HttpSendRequest($hHttpOpenRequest, $toSend, StringToBinary($JSONdata) )

            $vReceived = Binary("")
                $vReceived &= _WinINet_InternetReadFile($hHttpOpenRequest, 1024)
            Until @error <> 0 Or Not @extended



For other use, you must read that thread and the UDF doc.

Edited by frank10
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...