Hi,
Ok for the first problem
Ur function Url(addloc) = "http://www.google.co.uk" should return
www.google.co.uk and not the Http:// that is what is generating the error, I think due to the fact that Winsock does not know that u are using HTTP Protocol to communicate, and does not know how to handle the remote to be http://www.google.co.uk, but is fine when you only pass it www.google.co.uk as
Maybe trying something different might help, here is how you can use MSXML to do the same thing. Even though you can use this for XML data, but it can be used for normal HTTP operations also.Code:mkt.Protocol = sckTCPProtocol mkt.RemoteHost = "www.google.co.uk" mkt.RemotePort = 80 mkt.Connect
P.S. you can run it in both sync and async see MSDN for both complete examples.
Hope this helps, also to post the data, its the same.Code:Dim myHTTP Dim HTTPUrl As String Dim HTTPData As String HTTPUrl = "http://www.google.com" Set myHTTP = CreateObject("Msxml2.XMLHTTP") myHTTP.Open "GET", HTTPUrl, False myHTTP.setRequestHeader "Cache-Control", "no-cache" myHTTP.setRequestHeader "Accept-Language", "it" myHTTP.setRequestHeader "Content-type", "application/x-www-form-urlencoded" myHTTP.Send On Error Resume Next If Err.Number <> 0 Then HTTPData = "Bad URL" Else HTTPData = myHTTP.responsetext End If Set myHTTP = Nothing Debug.Print HTTPData
Code:Dim SendData Dim myHTTP Dim HTTPUrl As String Dim HTTPData As String HTTPUrl = "http://www.google.com" Set myHTTP = CreateObject("Msxml2.XMLHTTP") myHTTP.Open "POST", HTTPUrl, False myHTTP.setRequestHeader "Cache-Control", "no-cache" myHTTP.setRequestHeader "Accept-Language", "it" myHTTP.setRequestHeader "Content-type", "application/x-www-form-urlencoded" myHTTP.Send SendData On Error Resume Next If Err.Number <> 0 Then HTTPData = "Bad URL" Else HTTPData = myHTTP.responsetext End If Set myHTTP = Nothing Debug.Print HTTPData




Reply With Quote