Download MetaTrader 5
To add comments, please log in or register
Publish your article to let the traders see it in MetaTrader 5!
Georgiy Liashchenko
2410
Georgiy Liashchenko 2016.03.10 16:56 

Hello everyone,

 I ve been using WebRequest code provided by mt4 support and it was running perfectly, until today...

Server returns 200 which means authorization is ok, but even if i put wrong log/pass it is still 200. And cookie does not creates an auth= field, therefore authorization fails. So basically this code doesn't work anymore or i just don't understand something :( Please help to solve it, or suggest any other website which allow simple authorization. Thanks

 

bool Authorization()
  {
   if(IsTesting())return(true);
string   Login="login";        //Your account
string   Password="password";          //Your account password
   int    res;     // To receive the operation execution result
   char   data[];  // Data array to send POST requests
   string authurl="https://www.mql5.com/en/auth_login";
   string str="Login="+Login+"&Password="+Password;

   ArrayResize(data,StringToCharArray(str,data,0,WHOLE_ARRAY,CP_UTF8)-1);
   ResetLastError();
   res=WebRequest("POST",authurl,NULL,0,data,data,str);
   if(GetLastError()==4060)
     {
      Alert("You have not added ",authurl," to URL permition list in the ( Tools > Options > Expert Advisors tab )");
     }
   if(res!=200)
     {
      Print("Authorization failed!, LastError="+(string)res);
      return(false);
     }
     Print(res);
     Alert(str);
     
   res=StringFind(str,"Set-Cookie: auth=");
   if(res<0)
     {
      Alert("Login/Password failed!");
      return(false);
     }
   else Print("Authorized");

   return(true);
  }
Georgiy Liashchenko
2410
Georgiy Liashchenko 2016.03.10 18:53  

How to understand that the athorization with another website for example went successful? 

Thats what i get, login/pass are correct 

 

Alain Verleyen
Moderator
30295
Alain Verleyen 2016.03.10 22:29  
Metaquotes probably changed the login method.
/
To add comments, please log in or register