VB如何实现发送POST请求?

2025-03-06 19:12:03
推荐回答(3个)
回答1:

参考一下吧

Private Function ShowIe(ByVal url As String, ByVal user As String, ByVal sn As String)
On Error GoTo ex
'edtPostData.Text = "" ' Initialize an edit box for testing
ReDim aByte(0) As Byte ' Array of bytes to hold data to post
' Extract the URL encoded data from the UI,
' and pack it into an array of bytes
' cFlavor = cboFlavor.List(cboFlavor.ListIndex)
cParamName = "user="
cParamFlavor = "SN="
cSeparator = "&"
cPostData = cParamName & user _
& cSeparator & cParamFlavor & sn
PackBytes aByte(), cPostData
' For testing, rebuild the POST data and stuff
' it into an edit box
For i = LBound(aByte) To UBound(aByte)
edtPostData = edtPostData + Chr(aByte(i))
Next
Dim vPost As Variant
vPost = aByte ' Assign the byte array to a VARIANT
Dim vFlags As Variant
Dim vTarget As Variant
Dim vHeaders As Variant
vHeaders = _
"Content-Type: application/x-www-form-urlencoded" _
+ Chr(10) + Chr(13)
Dim objExplorer As Object
Set objExplorer = CreateObject("InternetExplorer.Application")

objExplorer.Navigate url, _
vFlags, vTarget, vPost, vHeaders objExplorer.Visible = True
Exit Function
ex:
End Function

回答2:

需要截取 post包 分析出他的真实网络地址和发送的参数包 来用vb post定义

回答3:

可以使用部件:Microsoft Internet Transfer Control