public static bool Authenticate(string username, string password)
        {
            using (var webClient = new CookieWebClient(CookieContainer))
            {
                HttpWebResponse error;
                string          response = PostString(webClient, "http://oxidemod.org/login/login", new NameValueCollection
                {
                    { "login", username },
                    { "password", password }
                }, out error);

                if (error != null)
                {
                    throw new ApiResponseException(global::Nancy.HttpStatusCode.InternalServerError, error.StatusDescription);
                }

                var htmlDoc = new HtmlDocument();
                htmlDoc.LoadHtml(response);

                var rootNode    = htmlDoc.DocumentNode;
                var accountMenu = rootNode.SelectSingleNode("//*[@id=\"AccountMenu\"]");

                return(accountMenu != null);
            }
        }
 protected static string PostString(CookieWebClient webClient, string url, NameValueCollection values, out HttpWebResponse errorResponse)
 {
     return(TryAction(() =>
     {
         byte[] bytes = webClient.UploadValues(url, "POST", values);
         return Encoding.UTF8.GetString(bytes);
     }, out errorResponse));
 }
 protected static string DownloadString(CookieWebClient webClient, string url, out HttpWebResponse errorResponse)
 {
     return(TryAction(() => webClient.DownloadString(url), out errorResponse));
 }
 protected BaseApi()
 {
     WebClient = new CookieWebClient(CookieContainer);
 }