MS Access执行POST Web请求 [英] MS Access perform POST webrequest
问题描述
在我的MS Access应用程序中,我需要定期向我的网络服务器发送一批信息.我不需要像SOAP,XML-RPC之类的东西,只要一个简单的POST页面请求就足够了.我已经用Google搜索了一下,但是无法提供真正有用的东西.
In my MS Access application I need to send a batch of info to my webserver on a regular basis. I don't need anything fancy like SOAP, XML-RPC or anything, just a simple POST page request is sufficient. I've Googled a bit but have been unable to turn up anything really helpful.
有人知道资源或有代码示例来执行此操作吗?
Does anyone know of a resource or have a code sample to perform this?
推荐答案
这里是我用于HTTP GET请求的地方,我想在其中检索网页的HTML.您可以将POST替换为pMethod参数,并丢弃响应文本.
Here is one I used for HTTP GET requests where I wanted to retrieve a web page's HTML. You could substitute POST for the pMethod parameter and discard the response text.
我使用了MSXML2,它不能保证在所有Windows版本中都可用.如果在您的系统上不可用,则可以尝试使用MSXML.或在MSXML2不可用时使用错误处理程序退回到MSXML.
I used MSXML2 which is not guaranteed to be available across all Windows versions. If it's not available on your systems, you could try MSXML instead. Or use an error handler to fall back to MSXML when MSXML2 not available.
Public Function HttpRequest(ByVal pUrl As String, _
Optional ByVal pMethod As String = "GET") As String
Dim strResponse As String
Dim objHttp As Object
'use "MSXML.XMLHTTPRequest" if MSXML2 not available '
Set objHttp = CreateObject("MSXML2.XMLHTTP")
objHttp.Open pMethod, pUrl, False
objHttp.send
strResponse = objHttp.responseText
HttpRequest = strResponse
Set objHttp = Nothing
End Function
这篇关于MS Access执行POST Web请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!