當前位置:編程學習大全網 - 源碼下載 - VB HTTPS POST

VB HTTPS POST

首選添加引用:microsoft xml 6.0 我用的是6.0 如果妳沒有去安裝xml6吧。

添加完成後,添加以下代碼即可完成POST數據發送

Option Explicit

Dim xml As XMLHTTP60

Private Sub Command1_Click()

xml.open "POST", "/", True '註明是POST請求,當然也可以get

xml.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"

Dim str As String

str = str & "wd=關鍵" '可以在這裏添加參數

str = p_URLEncoding(str) '需要將POST的數據進行編碼

xml.send str

End Sub

Private Sub Form_Load()

Set xml = New XMLHTTP60

End Sub

'編碼函數

Private Function p_URLEncoding(vstrIn) As String

'/////////////////////////////////////////////////

'解決編碼轉換問題 POST GB2312 編輯的數據

Dim i As Long

Dim strReturn As String

Dim ThisChr As String

Dim innerCode As Long

Dim Hight8 As Long

Dim Low8 As Long

strReturn = ""

For i = 1 To Len(vstrIn)

ThisChr = Mid(vstrIn, i, 1)

If Abs(Asc(ThisChr)) < &HFF Then

strReturn = strReturn & ThisChr

Else

innerCode = Asc(ThisChr)

If innerCode < 0 Then

innerCode = innerCode + &H10000

End If

Hight8 = (innerCode And &HFF00) \ &HFF

Low8 = innerCode And &HFF

strReturn = strReturn & "%" & Hex(Hight8) & "%" & Hex(Low8)

End If

Next

p_URLEncoding = strReturn

End Function

  • 上一篇:妳小學的時候,做過什麽轟動全校的事嗎?
  • 下一篇:檸檬和冰糖的正確泡法
  • copyright 2024編程學習大全網