webrequest remote file check error

To add comments, please log in or register
james272
38
james272  

hello

i want to check url existence.

but even though url exist it return error.

i really can't figure out what wrong with it..i think it correct code.

but still return error.

anyone guide me much appreciate thanks!

   string cookie=NULL,headers;
   char post[],result[];
   int res;
   string google_url="http://www.hongbopro.com/readme.html";
   ResetLastError();
   int timeout=5000; 
   res=WebRequest("GET",google_url,cookie,NULL,timeout,post,0,result,headers);
//--- Checking errors
   if(res==-1)
     {
      Print("Error in WebRequest. Error code  =",GetLastError());
     
     }
   else
     {
      Print("file exist");
     }
Alain Verleyen
38701
Alain Verleyen  
james272:

hello

i want to check url existence.

but even though url exist it return error.

i really can't figure out what wrong with it..i think it correct code.

but still return error.

anyone guide me much appreciate thanks!

What error ?
Lorentzos Roussos
18988
Lorentzos Roussos  

Have you added your website in the allowed urls list ?

james272
38
james272  
Lorentzos Roussos:

Have you added your website in the allowed urls list ?

where should have to add allowed url list?

thanks!

james272
38
james272  
Alain Verleyen:
What error ?

whether url is exist or not it return error.

http://www.hongbopro.com/readme.html this url is exist url but still error return
Lorentzos Roussos
18988
Lorentzos Roussos  
james272:

where should have to add allowed url list?

thanks!

in MT4 go to Tools > Options > ExpertAdvisors , check the "Allow WebRequest for Listed Url" and add the url in the list.

james272
38
james272  
Lorentzos Roussos:

in MT4 go to Tools > Options > ExpertAdvisors , check the "Allow WebRequest for Listed Url" and add the url in the list.

unfortunetly it still same error return.

Alain Verleyen
38701
Alain Verleyen  
james272:

whether url is exist or not it return error.

I am asking you what is the error number !
nicholi shen
2392
nicholi shen  

Works fine for me. 

setup

void OnStart()
{
   string base_url   = "http://www.hongbopro.com";
   string endpoint   = "/readme.html";
   int timeout       = 5000; 
   string headers    = NULL;
   char  request[];
   char  response[];
   string response_headers = NULL;
   ResetLastError();
   int r = WebRequest(
      "GET",             // HTTP method 
      base_url + endpoint,// Full URL 
      headers,           // headers  
      timeout,           // timeout 
      request,           // the array of the HTTP message body 
      response,          // an array containing server response data 
      response_headers   // headers of server response 
   );
   
   if(r < 0)
      Alert(StringFormat("you forgot to whitelist %s, dummy", base_url));
   else if(r != 200)
      Alert(StringFormat("Error = ", GetLastError()));
   else
      Alert("SUCCESS!");
}
james272
38
james272  
nicholi shen:

Works fine for me. 

thanks so much!

but it return  "you forgot to whitelist http://www.hongbopro.com, dummy"

i using FXopen and platform version is 4.00 Build 1090

i think this error is more related with my mt4 platform?

what platform you are using?

thanks!

nicholi shen
2392
nicholi shen  
james272:

thanks so much!

but it return  "you forgot to whitelist http://www.hongbopro.com, dummy"

i using FXopen and platform version is 4.00 Build 1090

i think this error is more related with my mt4 platform?

what platform you are using?

thanks!

MT4 and MT5. There is an issue with the way you are white-listing the domain. Make sure you only input the domain and do not include any endpoints. 

http://www.hongbopro.com //YES

http://www.hongbopro.com/something.html //NO!!!
To add comments, please log in or register