An easy-to-use, general-purpose library for sending HTTP web requests in MQL5 using the WinINet DLL.
- 📁 \MQL5\Include\
- 📁 \MQL5\Scripts\
Introducing an easy-to-use, general-purpose library designed for seamless handling of HTTP web requests in MQL5 through the utilization of the WinINet DLL. This library simplifies the process of incorporating web request functionalities into your MQL5 projects, providing a user-friendly interface for developers. With its intuitive design, the library empowers users to effortlessly send and manage HTTP requests, offering a versatile solution for a wide range of applications within the MQL5 environment. Streamlining the integration of web communication capabilities, this library serves as a valuable resource for developers seeking efficient and reliable methods to interact with online resources in their MQL5 projects.
Example 1:
Send a GET request and retrieve current GMT time.
WininetRequest req;
WininetResponse res;
req.host = "worldtimeapi.org";
req.path = "/api/timezone/Europe/London.txt";
WebReq(req, res);
Print("status: ", res.status);
Print(res.GetDataStr());
Example 2:
Send a POST request and echo it back.
WininetRequest req;
WininetResponse res;
req.method = "POST";
req.host = "httpbin.org";
req.path = "/post";
req.port = 80;
req.headers = "Accept: application/json\r\n"
"Content-Type: application/json; charset=UTF-8\r\n";
req.data_str = "{'id': 10, 'title': 'foo', 'message': 'bar'}";
StringReplace(req.data_str, "'", "\"");
WebReq(req, res);
Print("status: ", res.status);
Print(res.GetDataStr());
Top comments (1)
It seems that Wininet doesn't run in Windows 7,
Do you have any idea?