vb6.0 winHttp的post或get一个函数

</pre><pre name="code" class="vb">'作用:winHttp的post或者get
'参数:postURL,post或get网址
'参数:postData,post内容
'参数:Method,方法,为"POST"或"GET"
'参数:setCookies,post或get带上的cookie
'返回:post或get返回的内容
Public Function winHttpGetResponse(postURL As String, postData As String, Method As String, setCookies As String) As String
    If Len(Trim(setCookies)) = 0 Then setCookies = "a:x," '//cookie为空则随便弄个cookie,不然报错
    Set WinHttp = CreateObject("WinHttp.WinHttpRequest.5.1") '创建WinHttp.WinHttpRequest
    'MsgBox "到 这里"
    WinHttp.Open Method, postURL, True '同步接收数据
    WinHttp.Option(WinHttpRequestOption_SslErrorIgnoreFlags) = &H3300 '非常重要(忽略错误)
     '其它请求头设置
     
    WinHttp.SetRequestHeader "Content-Type", "application/x-www-form-urlencoded"
    WinHttp.SetRequestHeader "Cookie", setCookies
    WinHttp.SetRequestHeader "Content-Length", Len(postData)
    WinHttp.Send postData '' 开始发送
    
    WinHttp.WaitForResponse '等待请求
    'MsgBox WinHttp.Status'请求状态
    '得到返回文本(或者是其它)
   winHttpGetResponse = WinHttp.ResponseText
End Function


评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值