从 vba 执行隐藏的 http 请求

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7254420/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-11 13:56:11  来源:igfitidea点击:

Perform hidden http-request from vba

ms-accessvbadll

提问by Teson

I want to perform a hidden HTTP-GETrequest from MS-access, as simple as possible, without any extra libraries/components.

我想HTTP-GET从 MS-access执行隐藏请求,尽可能简单,没有任何额外的库/组件。

Just a simple declare all needed.

只需一个简单的声明即可。

Has WinHttp left the building??

WinHttp 离开大楼了吗??

回答by Patrick Honorez

Here is a great pageabout that.

这是一个很棒的页面

回答by Adarsh Madrecha

Hope this helps

希望这可以帮助

 Dim xhr As Object
 Dim webServiceURL As String
 Dim actionType As String
 Dim thisRequest As String
 Dim targetWord As String

 WebServiceURL = "http://services.aonaware.com/DictService/DictService.asmx/"
 actionType = "Define?word="
 targetWord = "Marketplace"
 thisRequest = webServiceURL & actionType & targetWord

 'use late binding
 Set xhr = CreateObject("Microsoft.XMLHTTP")  

 xhr.Open "GET", thisRequest, False
 xhr.Send

 If xhr.status = 200 Then
   Debug.Print xhr.responseText
   MsgBox xhr.getAllResponseHeaders
 Else
   MsgBox xhr.status & ": " & xhr.statusText
 End If

 Set xhr = Nothing