使用BinaryToString转换字符串为UTF8还有部分乱码
; 初始化并获取会话句柄
$hOpen = _WinHttpOpen("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.55 Safari/537.36 Edg/96.0.1054.34")
; 获取连接句柄
$hConnect = _WinHttpConnect($hOpen, $sDomain)
; 设置请求
$hRequest = _WinHttpOpenRequest($hConnect, "POST", $sPage)
; 发送. 指定也要发送的其它数据. 这是 Google API 所必需的:
_WinHttpSendRequest($hRequest, "Content-Type: application/json; charset=utf-8" , $sAdditionalData)
; 等待响应
_WinHttpReceiveResponse($hRequest)
; 看看返回的是什么
Dim $sReturned
If _WinHttpQueryDataAvailable($hRequest) Then ; 如果有数据
Do
$sReturned &= _WinHttpReadData($hRequest)
Until @error
EndIf; 关闭句柄
_WinHttpCloseHandle($hRequest)
_WinHttpCloseHandle($hConnect)
_WinHttpCloseHandle($hOpen)
; 看看返回的是什么
MsgBox(4096, "返回", BinaryToString($sReturned,4))
MsgBox(4096, "返回", BinaryToString($sReturned,1)) 二进制发出来看下
Do .. $sReturned &= _WinHttpReadData($hRequest) 感觉不可靠 afan 发表于 2021-11-27 11:56
Do .. $sReturned &= _WinHttpReadData($hRequest) 感觉不可靠
求大神指点 zghwelcome 发表于 2021-11-27 08:50
MsgBox(4096, "返回", BinaryToString($sReturned,1))
这个不行,已经搞定了。
_WinHttpReadData($hRequest,1)
页:
[1]