Semplice POST/GET HttpRequest con mql4 - pagina 3

 
coolex:

Se faccio la modifica, ricevo il messaggio di errore "'&' - reference cannot used".


Era solo un suggerimento, non una guida.
 
Quale build di MT4 stai usando?
 

Io uso Build 610.

 
coolex:

Io uso la build 610.


Sto anche cercando di usare il codice e mi dà errori di "Access Violation" con la build 610.

Come da questo post (https://www.mql5.com/en/articles/276) gli utenti su MQL5 stanno ottenendo lo stesso problema ....

B&KR.

 

Sto usando la B617 e funziona bene, sto per installare la B610 per verificarla.

siprega di essere paziente ;-)
 

Ok, eccoci qui (fissato per 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 questo esempio funziona per

#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! Entrambi gli esempi funzionano. Grazie mille.

 
sergiensergien:

Come da questo post (https://www.mql5.com/en/articles/276) gli utenti su MQL5 stanno avendo lo stesso problema ....



è un motivo diverso per cui ottengono l'errore, ma qui c'è MQL4 quindi...
 
coolex:

GRANDE! Entrambi gli esempi funzionano. Grazie mille.


Penso che dovresti usare i parametri giusti (o tutti)

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