【问题标题】:default credentials in VBAVBA 中的默认凭据
【发布时间】:2014-06-03 12:18:22
【问题描述】:

我正在尝试从 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

但我在需要基本身份验证 (base64) 的代理服务器后面。

如何在 VBA 中设置凭据?

(相当于:myHttpWebRequest.Credentials = CredentialCache.DefaultCredentials)

如果这不可能,如何用另一种方法解决问题?

谢谢!

【问题讨论】:

标签: vba proxy httpclient


【解决方案1】:

您需要 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

取自 This Question,其中指出 2 参数是您可能需要更改的版本号。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-01-25
    • 2018-02-06
    • 2017-05-21
    • 2015-10-17
    • 2018-04-01
    • 2013-08-01
    • 2011-01-29
    相关资源
    最近更新 更多