Example #1
0
        public string Posting(string log, string pass)
        {
            var client  = new RestClient(" http://bmhmh.ho.ua");
            var request = new RestRequest("/index.php/api/login", Method.POST);

            request.AddJsonBody(JsonConvert.SerializeObject(
                                    new
            {
                login    = DataCryptography.EncryptString(log, DataCryptography.key, DataCryptography.iv),
                password = DataCryptography.EncryptString(pass, DataCryptography.key, DataCryptography.iv)
            }));

            IRestResponse  response          = client.Execute(request);
            HttpStatusCode statusCode        = response.StatusCode;
            int            numericStatusCode = (int)statusCode;

            if (numericStatusCode == 200)
            {
                var content = response.Content;
                if (content == "{\"response\":\"Wrong login" + "/password!\"}")
                {
                    return("Wrong pass");
                }
                else
                {
                    TokenController._token       = JsonConvert.DeserializeObject <CurrentToken>(content);
                    TokenController._token.token = DataCryptography.DecryptString(TokenController._token.token, DataCryptography.key, DataCryptography.iv);

                    return(TokenController.GetInstance().token);
                }
            }
            else
            {
                return("No Connection");
            }
        }
Example #2
0
 public void Launch()
 {
     currentToken = TokenController.GetInstance();
 }