函数参考


_WinHttpSimpleSendRequest

使用HTTP请求发送一个简单的表单,但不读取数据

#Include <WinHttp.au3>
_WinHttpSimpleSendRequest($hConnect, $sType, $sPath [, $sReferrer = Default [, $sData = Default [, $sHeader = Default ]]])

参数

$hConnect _WinHttpConnect 函数返回的句柄.
$sType [可选参数] GET 或 POST (默认: GET)
$sPath [可选参数] 请求路径 (默认: "" - 空字符串;表示服务器上的默认页)
$sReferrer [可选参数] 引用页面 (默认: $WINHTTP_NO_REFERER)
$sData [可选参数] POST数据 (默认: $WINHTTP_NO_REQUEST_DATA)
$sHeader [可选参数] 附加头 (默认: $WINHTTP_NO_ADDITIONAL_HEADERS)

返回值

成功: 返回 _WinHttpReceiveResponse 函数之后的请求句柄.
失败: 返回 0 并设置@error
1 - 无法打开请求
2 - 无法发送请求
3 - 无法接收响应

注意/说明

None.

相关

_WinHttpSimpleRequest, _WinHttpSimpleSendSSLRequest, _WinHttpSimpleReadData

示例/演示


#AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6

#include "WinHttp.au3"

Opt("MustDeclareVars", 1)

; 初始化并获取会话句柄
Global $hOpen = _WinHttpOpen()
; 获取连接句柄
Global $hConnect = _WinHttpConnect($hOpen, "w3schools.com")
; 生成请求
Global $hRequest = _WinHttpSimpleSendRequest($hConnect, Default, "tags/tag_input.asp")

If $hRequest Then
    ; 简单读取...
    ConsoleWrite(_WinHttpSimpleReadData($hRequest) & @CRLF)
    MsgBox(64, "Okey do!", "Returned source is print to concole. Check it.")
Else
    MsgBox(48, "Error", "Error ocurred for _WinHttpSimpleSendRequest, Error number is " & @error)
EndIf

; 关闭句柄
_WinHttpCloseHandle($hRequest)
_WinHttpCloseHandle($hConnect)
_WinHttpCloseHandle($hOpen)