VB如何实现发送POST请求?
VB如何实现发送连带GET和POST请求?亦即直接POST发送到包含GET参数的URL里。关键还是讨论如何用VB发送POST参数。...
VB如何实现发送连带GET和POST请求?亦即直接POST发送到包含GET参数的URL里。关键还是讨论如何用VB发送POST参数。
展开
3个回答
展开全部
参考一下吧
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
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
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
需要截取 post包 分析出他的真实网络地址和发送的参数包 来用vb post定义
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
可以使用部件:Microsoft Internet Transfer Control
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询