mardi 25 septembre 2018

C# - Login to website from console application

there is a website I want to try to log in from console application, at the moment I use a library called xNet, and I got all the information I need with Fiddler.

when I start the program, it doesn't work, I added all the information, and still it just downloaded me the page source code.

Link to website: https://www.skipthedishes.com/

My Code:

CookieDictionary cookieJar; // Use if you need to get Cookies
        using (var request = new HttpRequest())
        {
            //request.Proxy = HttpProxyClient.Parse("127.0.0.1:8888"); // Fiddler proxy
            cookieJar = new CookieDictionary(); // Only if you need to get Cookies
            request.Cookies = cookieJar; // The request cookies = cookiejar cookies
            request.IgnoreProtocolErrors = true; // Ignore Any errors
            request.KeepAlive = true;
            request.ConnectTimeout = 10000;
            request.AllowAutoRedirect = false;
            request.UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.140 Safari/537.36 Edge/17.17134";
            request.AddParam("email", "danielki887465@gmail.com"); // If it's in WebForms type then use this
            request.AddParam("password", "123"); // If it's in WebForms type then use this

            request.AddHeader("Origin", "https://www.skipthedishes.com");
            request.AddHeader("Host ", "www.skipthedishes.com"); // Search for the Host
            cookieJar.Add("cto_lwid", "049e61f4-fcdd-4f28-ac53-f1ce13c9cc40"); // Add Cookies to here
            cookieJar.Add("_ga", "GA1.2.1520958558.1537913597"); // Add Cookies to here
            cookieJar.Add("_gid", "GA1.2.73030699.1537913597"); // Add Cookies to here
            cookieJar.Add("__zlcmid", "oZhfa9ad7gHAbO"); // Add Cookies to here
            cookieJar.Add("visid_incap_1014357", "YqrbddCwQkSJaqPK7nCt5LiyqlsAAAAAQkIPAAAAAACAqhyHAWiBEiBwkV2hPw0z9BH0mP7g6o3f"); // Add Cookies to here
            cookieJar.Add("incap_ses_438_1014357", "/6PqWWl0AzRFSmnlnRgUBgG/qlsAAAAAIW6EM2ccKQfZ/hakG+a33A=="); // Add Cookies to here
            cookieJar.Add("incap_ses_484_1014357", "hdyAC6y7Zkmu9/f9FIS3Blq/qlsAAAAAU2zCtEQaMtAsUzONKRnQ0w=="); // Add Cookies to here
            cookieJar.Add("skip_auth", @"""e30\075 | 1537917001 | "); // Add Cookies to here

            request.Referer = "https://www.skipthedishes.com/"; // Search For referer
            HttpResponse respone = request.Post("https://www.skipthedishes.com/user/login/json"); // Just paste the URL Here
            var attempt = request.Post("https://www.skipthedishes.com/user/login/json").ToString(); // Just paste the URL here
            Console.WriteLine(attempt); // Print the Debug and results of the code to see if everything is working
        }
        Console.ReadKey();

I got the cookies with fiddler.

What I want it to do:

I want to be able to login to the website from the console application.




Aucun commentaire:

Enregistrer un commentaire