WebSession for MQL

 

I wanted to share this project with the community, but I don't have the time to properly document it and share it in the codebase. WebSession is a high-level framework for creating a persistent web session object. Those with a solid programming background should find this easy to use and self-documented. The README has all the necessary steps to get started. Have fun with it! 


Example: 

bool test_post_rates()
{
   string res_name = NULL;
   string acc_name = AccountInfoString(ACCOUNT_NAME);
   
   WebSession x("https://postman-echo.com/post");
   x.headers_request()["Content-Type"] = "application/json";
   
   Json json;
   json["account_name"] = acc_name;
   MqlRates r[];
   CopyRates(_Symbol, PERIOD_CURRENT, 0, 2, r);
   for(int i=0; i<2; i++){
      json["rates"][i]["close"] = r[i].close;
      json["rates"][i]["volume"] = r[i].tick_volume;
   }
   if(x.request_body(json).POST().status_code() == 200){
      json.Deserialize(x.json()["data"].ToStr());
      res_name = json["account_name"].ToStr();
   }
   return acc_name == res_name;
}