Private Sub Command4_Click()
Dim oHttp As Object
Set oHttp = CreateObject("WinHttp.WinHttpRequest.5.1")
' 设置请求的 URL 和方法(GET 或 POST)
oHttp.Open "GET", "APIURL(https://......)", False
' 可以设置请求头、发送数据等其他配置(根据需要进行修改)
oHttp.setRequestHeader "Content-Type", "application/json"
oHttp.setRequestHeader "Authorization", "Bearer token123"
' 发送请求
oHttp.Send
' 获取响应内容
Dim responseText As String
responseText = oHttp.responseText
' 可以对响应内容进行处理,比如解析 JSON 数据等
MsgBox responseText
' 释放资源
Set oHttp = Nothing
End Sub
VB6调用API接口
最新推荐文章于 2025-04-11 15:58:13 发布