Simple POST/GET HttpRequest avec mql4 - page 3

 
coolex:

Si je fais la modification, je reçois le message d'erreur "'&' - reference cannot used".


C'était juste une indication, pas un guide.
 
Quelle version de MT4 utilisez-vous ?
 

J'utilise Build 610.

 
coolex:

J'utilise la version 610.


J'essaie également d'utiliser le code et il me donne des erreurs "Access Violation" avec la build 610.

Selon ce post (https://www.mql5.com/en/articles/276), les utilisateurs de MQL5 rencontrent le même problème : .....

B&KR.

 

J'utilise B617 et ça marche très bien. Je vais installer B610 pour vérifier.

merci d' être patient ;-)
 

ok voilà (corrigé pour 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);
 

et cet exemple fonctionne pour

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

GÉNIAL ! Les deux exemples fonctionnent. Merci beaucoup.

 
sergiensergien:

Selon cet article (https://www.mql5.com/en/articles/276), les utilisateurs de MQL5 rencontrent le même problème .....



La raison pour laquelle ils obtiennent l'erreur est différente, mais voici MQL4 donc...
 
coolex:

GÉNIAL ! Les deux exemples fonctionnent. Merci beaucoup.


Je pense que vous devez utiliser les bons paramètres (ou tous les paramètres).

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