mql4를 사용한 간단한 POST/GET HttpRequest - 페이지 3

 
coolex :

변경하면 "'&' - 참조를 사용할 수 없습니다"라는 오류 메시지가 나타납니다.


안내가 아니라 힌트일 뿐이었다.
 
어떤 MT4 빌드를 사용하고 있습니까?
 

저는 빌드 610을 사용합니다.

 
coolex :

저는 빌드 610을 사용합니다.


또한 코드를 사용하려고 하는데 빌드 610에서 "액세스 위반" 오류가 발생합니다.

이 게시물(https://www.mql5.com/en/articles/276)에 따르면 MQL5 사용자는 동일한 문제를 겪고 있습니다.

B&KR.

 

저는 B617을 사용하고 있으며 잘 작동합니다. 확인 하기 위해 B610을 설치하겠습니다.

기다려주세요 ;-)
 

자 이제 시작합니다(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);
 

이 예제는

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

엄청난! 두 예제 모두 작동합니다. 정말 감사합니다.

 
sergiensergien :

이 게시물(https://www.mql5.com/en/articles/276)에 따르면 MQL5 사용자는 동일한 문제를 겪고 있습니다.



오류가 발생하는 이유는 다르지만 여기에 MQL4가 있으므로...
 
coolex :

엄청난! 두 예제 모두 작동합니다. 정말 감사합니다.


올바른 매개변수 (또는 모든 매개변수)를 사용해야 한다고 생각합니다.

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