VBA中的默认凭据
我正在尝试从VB向应用程序(VBA)发出HTTP请求 这应该很简单:VBA中的默认凭据,vba,proxy,httpclient,Vba,Proxy,Httpclient,我正在尝试从VB向应用程序(VBA)发出HTTP请求 这应该很简单: URL = "https://www.google.com/" Set xhr = CreateObject("MSXML2.ServerXMLHTTP.6.0") xhr.Open "GET", URL, False xhr.setRequestHeader "Content-Type", "application/x-www-form-urlencoded" xhr.Send MsgBox xhr.responseText
URL = "https://www.google.com/"
Set xhr = CreateObject("MSXML2.ServerXMLHTTP.6.0")
xhr.Open "GET", URL, False
xhr.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
xhr.Send
MsgBox xhr.responseText
但我支持一个需要基本身份验证(base64)的代理服务器
如何在VBA中设置凭据
(相当于:myHttpWebRequest.Credentials=CredentialCache.DefaultCredentials)
如果不可能,如何用另一种方法解决问题
谢谢 您需要setProxyCredentials方法。我没有要测试的代理,但这应该可以做到:
URL = "https://www.google.com/"
Set xhr = CreateObject("MSXML2.ServerXMLHTTP.6.0")
xhr.Open "GET", URL, False
xhr.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
xhr.setProxy 2, "192.168.0.222:8080"
xhr.setProxyCredentials "your_username" , "password_for_username"
xhr.Send
MsgBox xhr.responseText
从中可以看出,2参数是您可能需要更改的版本号。您可以将此VBScript改编为VBA:虽然有点晚,但这可能会有所帮助。如果代理使用登录用户,如果代理配置为internet explorer。