Simples POST/GET HttpRequest com mql4 - página 4

 
qjol:

acho que você deve usar os parâmetros certos (ou todos eles)



Coisas!
 

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_PRAGMA_NOCACHE 0x00000100

int hSession_IEType;

int hSession_Direct;

int Internet_Open_Type_Preconfig = 0;

int Internet_Open_Type_Direct = 1;

int hSession_Direct(bool Direct)

{

string InternetAgent = "Mozilla/4.0 (compatível; MSIE 6.0; Windows NT 5.1; Q312461)";

se (Direto)

{

se (hSession_Direct == 0)

{

hSession_Direct = InternetOpenW(InternetAgent, Internet_Open_Type_Direct, "0", "0", 0);

}

return(hSession_Direct);

}

senão

{

se (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"){

cabeçalhos de corda = "Content-Type: application/x-www-form-urlencoded";

dados da string = "a=123";

char data[];

StringToCharArray(dados,dados);

int HttpOpen = hSession(false);

int HttpConnect = InternetConnectW(HttpOpen, strUrl, port, "", "", 3, 0, 0, 0);

int HttpRequest = HttpOpenRequestW(HttpConnect, "POST", idxfile, "", "", NULL, 0, 0);

bool result = HttpSendRequestW(HttpRequest, cabeçalhos, StringLen(cabeçalhos), dados, StringLen(dados));

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 ("Last MSDN Error =: ",err);

int read[1];

Print("Este é o resultado do POST: ", resultado);

Print(toStr);

InternetCloseHandle(HttpOpen);

InternetCloseHandle(HttpRequest);

}


httpPost("www.test.com",80);

 
erro12005 Você pode ter que usar 127.0.0.1 em vez de localhost. Eu tinha esse problema e ele o corrige.
Onde

você pode resolver isso. porque eu posso fazer o pedido de obtenção e postagem, mas o servidor está recebendo um arquivo vazio. Eu não consigo encontrar a maneira de enviar um arquivo json ou string
qjol
qjol
  • www.mql5.com
Added topic I'm tired why i'm tired ? ho, let me think.. maybe because people ask questions without providing deatails or maybe because people ask questions that can easily get answered using a quick Search (top right corner on every page) or google or maybe because Added topic The Function StringToInteger() has been made in a hurry    long...