![MQL5 - Lenguaje de estrategias comerciales para el terminal de cliente MetaTrader 5](https://c.mql5.com/i/registerlandings/logo-2.png)
Está perdiendo oportunidades comerciales:
- Aplicaciones de trading gratuitas
- 8 000+ señales para copiar
- Noticias económicas para analizar los mercados financieros
Registro
Entrada
Usted acepta la política del sitio web y las condiciones de uso
Si no tiene cuenta de usuario, regístrese
creo que debe utilizar los parámetros correctos (o todos ellos)
¡Gracias!
bool HttpSendRequestW(int hRequest, string lpszHeaders, int dwHeadersLength, char &lpOptional[], int dwOptionalLength);
#define INTERNET_FLAG_RELOAD 0x80000000
#define INTERNET_FLAG_NO_CACHE_WRITE 0x04000000
#define INTERNET_FLAG_PRAGMA_NOCACHE 0x00000100
int hSession_IEType;
int hSession_Direct;
int Internet_Open_Type_Preconfig = 0;
int Internet_Open_Type_Direct = 1;
int hSession(bool Direct)
{
string InternetAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; Q312461)";
si (Direct)
{
if (hSession_Direct == 0)
{
hSession_Direct = InternetOpenW(InternetAgent, Internet_Open_Type_Direct, "0", "0", 0);
}
return(hSession_Direct);
}
else
{
si (hSession_IEType == 0)
{
hSession_IEType = InternetOpenW(InternetAgent, Internet_Open_Type_Preconfig, "0", "0", 0);
}
return(hSession_IEType);
}
}
void httpPost(string strUrl,int port,string idxfile = "index.php"){
string headers = "Content-Type: application/x-www-form-urlencoded";
string data = "a=123";
char datos[];
StringToCharArray(data,datas);
int HttpOpen = hSession(false);
int HttpConnect = InternetConnectW(HttpOpen, strUrl, port, "", "", 3, 0, 0);
int HttpRequest = HttpOpenRequestW(HttpConnect, "POST", idxfile, "", "", NULL, 0, 0);
bool result = HttpSendRequestW(HttpRequest, headers, StringLen(headers), datas, StringLen(data));
uchar ch[100]; string toStr=""; int dwBytes, h=-1;
while(InternetReadFile(HttpRequest, ch, 100, dwBytes))
{
if (dwBytes<=0) break; toStr=toStr+CharArrayToString(ch, 0, dwBytes);
}
int err = GetLastError();
if(err>0)Print ("Último error MSDN =: ",err);
int read[1];
Print("Este es el resultado de POST: ", result);
Print(toStr);
InternetCloseHandle(HttpOpen);
InternetCloseHandle(HttpRequest);
}
httpPost("www.test.com",80);
Donde
has podido resolver esto, porque puedo hacer peticiones get y post pero el servidor recibe un archivo vacío. No puedo encontrar la manera de enviar un archivo json o una cadena