- SocketCreate
- SocketClose
- SocketConnect
- SocketIsConnected
- SocketIsReadable
- SocketIsWritable
- SocketTimeouts
- SocketRead
- SocketSend
- SocketTlsHandshake
- SocketTlsCertificate
- SocketTlsRead
- SocketTlsReadAvailable
- SocketTlsSend
- WebRequest
- SendFTP
- SendMail
- SendNotification
WebRequest
发送 HTTP 请求到指定服务器。 该函数有两个版本:
1. 发送简单请求 使用内容-类型标题的"key=value"类型:application/x-www-form-urlencoded
int WebRequest(
|
2. 发送任何类型的请求 为了各种网络服务的更灵活互动指定自定义的标题设置。
int WebRequest(
|
参数
method
[in] HTTP 请求方法。
url
[in] URL 地址。
headers
[in] "key: value"类型的请求标题,以分行符 "\r\n"分隔。
cookie
[in] Cookie。
referer
[in] HTTP 请求标头的推荐页字段
timeout
[in] 超时时间以毫秒为单位。
data[]
[in] HTTP 请求信息数组。
data_size
[in] data[] 数组大小。
result[]
[out] 服务器响应数据数组。
result_headers
[out] 服务器响应标头。
返回值
服务器响应的HTTP 状态码,或错误情况下的 -1 。
注意
若要能够使用WebRequest 函数,您必须在“选项”窗口“EA交易”标签的允许URLs列表中添加一个URL。
WebRequest 是一个同步函数。这意味着它会阻止程序执行并且等候请求服务器的响应。当收到发送请求的响应时,延迟至关重要,这就是禁止从指标调用该函数的原因,因为指标按照交易品种组指标的自己的执行线程操作。在一个图表上执行指标延迟可能导致该交易品种的所有图表停止更新。
该函数只能从专家和脚本调用,因为他们按照自己的执行线程操作。从指标调用,GetLastError() 函数将返回错误4014 "函数不允许调用"。
WebRequest() 函数不能在 策略测试中执行。
例如:
void OnStart()
|