Hi, I have googled through everything and I'm unable to get POST working. The GET works just fine. I don't want to use WebRequest because I need
asynchronous calls (not waiting for response)
Here's the most cleanest code I found. With all the found scripts the result is always 0
//+------------------------------------------------------------------+//| Wininet.mqh |//| Version: 1.0 |//| Copyright 2015, Wemerson C. Guimaraes |//| https://www.mql5.com/pt/users/wemersonrv/seller |//+------------------------------------------------------------------+#property copyright"Copyright 2015, Wemerson C. Guimaraes"#property link"https://www.mql5.com/pt/users/wemersonrv/seller"#import "Wininet.dll"int InternetOpenA(string, int, string, string, int);
int InternetConnectA(int, string, int, string, string, int, int, int);
int InternetOpenUrl(int, string, string, int, int, int);
int InternetReadFile(int, string, int, int& OneInt[]);
int InternetCloseHandle(int);
int HttpOpenRequestA(int, string, string, string, string, string& AcceptTypes[], int, int);
bool HttpSendRequestA(int, string, int, string, int);
#import
//+------------------------------------------------------------------+//| Expert initialization function |//+------------------------------------------------------------------+intOnInit()
{
//---string headers = "Content-Type: application/x-www-form-urlencoded";
string data = "";
string acceptTypes[1] = {"*/*"};
int HttpOpen = InternetOpenA("HTTP_Client_Sample", 1, NULL, NULL, 0);
int HttpConnect = InternetConnectA(HttpOpen, "localhost/tradex", 8000, NULL, NULL, 3, 0, 1);
int HttpRequest = HttpOpenRequestA(HttpConnect, "POST", "/index.php", "HTTP/1.1", NULL, acceptTypes, 0, 1);
string result = HttpSendRequestA(HttpRequest, headers, StringLen(headers), data, StringLen(data));
int read[1];
Print("This is the POST result: " + result);
return(0);
//---return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+//| Expert deinitialization function |//+------------------------------------------------------------------+voidOnDeinit(constint reason)
{
//---
}
//+------------------------------------------------------------------+//| Expert tick function |//+------------------------------------------------------------------+voidOnTick()
{
//---
}
//+------------------------------------------------------------------+
Hi, I have googled through everything and I'm unable to get POST working. The GET works just fine. I don't want to use WebRequest because I need asynchronous calls (not waiting for response)
Here's the most cleanest code I found. With all the found scripts the result is always 0