|
WebRequestThe function sends an HTTP request to a specified server. The function has two versions: 1. Sending simple requests of type "key=value" using the header Content-Type: application/x-www-form-urlencoded.
2. Sending a request of any type specifying the custom set of headers for a more flexible interaction with various Web services.
Parameters method [in] HTTP method. url [in] URL. headers [in] Request headers of type "key: value", separated by a line break "\r\n". cookie [in] Cookie value. referer [in] Value of the Referer header of the HTTP request. timeout [in] Timeout in milliseconds. data[] [in] Data array of the HTTP message body. data_size [in] Size of the data[] array. result[] [out] An array containing server response data. result_headers [out] Server response headers. Returned value HTTP server response code or -1 for an error. Note To use the WebRequest() function, add the addresses of the required servers in the list of allowed URLs in the "Expert Advisors" tab of the "Options" window. Server port is automatically selected on the basis of the specified protocol - 80 for "http://" and 443 for "https://". The WebRequest() function is synchronous, which means its breaks the program execution and waits for the response from the requested server. Since the delays in receiving a response can be large, the function is not available for calls from the indicators, because indicators run in a common thread shared by all indicators and charts on one symbol. Indicator performance delay on one of the charts of a symbol may stop updating of all charts of the same symbol. The function can be called only from Expert Advisors and scripts, as they run in their own execution threads. If you try to call the function from an indicator, GetLastError() will return error 4060 - "Function is not allowed for call". WebRequest() cannot be executed in the Strategy Tester. An example of using the first version of the WebRequest () function:
|