Example #1
0
        public async Task <Account> Login()
        {
            HttpUtil.AddCookie("noscript", "1", "facebook.com");

            var loginPage = await HttpUtil.GetAsync(LOGIN_ENDPOINT);

            var form = HtmlForm.CreateFromHtmlString("login_form", loginPage);

            form.InputElements.Add(new InputElement("login", "1"));
            form.InputElements.ForEach(x =>
            {
                if (x.Name == "email")
                {
                    x.Value = _username;
                }
                if (x.Name == "pass")
                {
                    x.Value = _password;
                }
            });
            var content = HttpUtil.CreateHttpContent(form);

            var speakyPage = await HttpUtil.PostAsync("https://www.facebook.com" + form.Action.HttpDecode(), content, HttpUtil.LocationUrl);

            if (!HttpUtil.LocationUrl.Contains("speaky.com/home"))
            {
                return(null);
            }
            return(new Account(LogInMethod.Facebook));
        }