Simple POST/GET HttpRequest con mql4 - página 3

 
coolex:

Si hago el cambio recibo el mensaje de error "'&' - no se puede utilizar la referencia".


Era sólo una pista, no una guía.
 
¿Qué versión de MT4 está utilizando?
 

Yo uso el Build 610.

 
coolex:

Utilizo la Build 610.


También estoy intentando utilizar el código y me da errores de "Violación de acceso" con la build 610.

Según este post (https://www.mql5.com/en/articles/276) los usuarios de MQL5 tienen el mismo problema ....

B&KR.

 

Estoy usando B617 y funciona muy bien voy a instalar B610 para comprobarlo

por favor, sea paciente ;-)
 

ok aquí vamos (arreglado 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);
 

y este ejemplo sirve 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);
 

¡GENIAL! Ambos ejemplos funcionan. Muchas gracias.

 
sergiensergien:

Según este post (https://www.mql5.com/en/articles/276) los usuarios de MQL5 tienen el mismo problema ....



es una razón diferente por la que reciben el error, pero aquí es MQL4 así...
 
coolex:

¡GENIAL! Ambos ejemplos funcionan. Muchas gracias.


creo que debes usar los parámetros correctos (o todos ellos)

#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);   

Razón de la queja: