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

 
coolex:

Se eu fizer a mudança, recebo a mensagem de erro "'&' - referência não pode ser usada".


Foi apenas uma dica, não um guia.
 
o que o MT4 constrói você está usando ?
 

Eu uso o Build 610.

 
coolex:

Eu uso o Build 610.


Também estou tentando usar o código e ele me dá erros de "Violação de Acesso" com o Build 610.

De acordo com este post (https://www.mql5.com/en/articles/276) os usuários da MQL5 estão tendo o mesmo problema ....

B&KR.

 

estou usando o B617 e funciona muito bem vou instalar o B610 para verificar

por favor, seja paciente ;-)
 

ok aqui vamos nós (fixo para B610)

#import  "Wininet.dll"
   int InternetOpenW(string, int, string, string, int);
   int InternetConnectW(int, string, int, string, string, int, int, int); 
   int InternetOpenUrlW(int, string, string, int, int, int);
   int InternetReadFile(int, string, int, int& OneInt[]);
   int InternetCloseHandle(int); 
   int HttpOpenRequestW(int, string, string, string, string, char& AcceptTypes[], int, int);
   bool HttpSendRequestW(int, string, int, string, int);
#import
#import "kernel32.dll"
int GetLastError(void);
#import


   string headers = "Content-Type: application/x-www-form-urlencoded";
   string data = "";
   string Types = "";
   char acceptTypes[];
   StringToCharArray(Types, acceptTypes);
   int HttpOpen = InternetOpenW(" ", 0, " ", "", 0);  
   int HttpConnect = InternetConnectW(HttpOpen, "www.forexfactory.com", 80, "", "", 3, 0, 0);
   int HttpRequest = HttpOpenRequestW(HttpConnect, "GET", "ff_calendar_thisweek.xml", "", "", acceptTypes, 0, 0);   
   bool result = HttpSendRequestW(HttpRequest, headers, StringLen(headers), data, StringLen(data));
   Alert ("Last MSDN Error =: ", kernel32::GetLastError());
   int read[1];
   Print("This is the POST result: ", result);
   InternetCloseHandle(HttpOpen);
   InternetCloseHandle(HttpRequest);
 

e este exemplo funciona para

#import  "Wininet.dll"
   int InternetOpenW(string, int, string, string, int);
   int InternetConnectW(int, string, int, string, string, int, int, int); 
   int InternetOpenUrlW(int, string, string, int, int, int);
   int InternetReadFile(int, string, int, int& OneInt[]);
   int InternetCloseHandle(int); 
   int HttpOpenRequestW(int, string, string, string, string, string, int, int);
   bool HttpSendRequestW(int, string, int, string, int);
#import
#import "kernel32.dll"
int GetLastError(void);
#import


   string headers = "Content-Type: application/x-www-form-urlencoded";
   string data = "";
   int HttpOpen = InternetOpenW(" ", 0, " ", "", 0);  
   int HttpConnect = InternetConnectW(HttpOpen, "www.forexfactory.com", 80, "", "", 3, 0, 0);
   int HttpRequest = HttpOpenRequestW(HttpConnect, "GET", "ff_calendar_thisweek.xml", "", "", data, 0, 0);   
   bool result = HttpSendRequestW(HttpRequest, headers, StringLen(headers), data, StringLen(data));
   Alert ("Last MSDN Error =: ", kernel32::GetLastError());
   int read[1];
   Print("This is the POST result: ", result);
   InternetCloseHandle(HttpOpen);
   InternetCloseHandle(HttpRequest);
 

GRANDE! Ambos os exemplos funcionam. Muito obrigado.

 
sergiensergien:

De acordo com este post (https://www.mql5.com/en/articles/276) os usuários da MQL5 estão tendo o mesmo problema ....



é uma razão diferente para eles receberem o erro, mas aqui está a MQL4 então...
 
coolex:

GRANDE! Ambos os exemplos funcionam. Muito obrigado.


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

#define  INTERNET_FLAG_PRAGMA_NOCACHE   0x00000100  // no caching of page
#define  INTERNET_FLAG_KEEP_CONNECTION  0x00400000  // keep connection
#define  INTERNET_FLAG_RELOAD           0x80000000  // get page from server when calling it

int HttpRequest = HttpOpenRequestW(HttpConnect, "GET", "ff_calendar_thisweek.xml", "", "", 0, 
INTERNET_FLAG_KEEP_CONNECTION|INTERNET_FLAG_RELOAD|INTERNET_FLAG_PRAGMA_NOCACHE, 0);