How can I write a .NET application that will automatically go to www.yahoo.com?

The following code is not included in the yahoo system. How to rewrite it?

(Of course, the "username" and "password" will be replaced by my actual account name and password.)

    static void Main(string[] args)
    {
        string input = string.Format("username={0}&passwd={1}", "<username>", "<password>");

        WebRequest request = HttpWebRequest.Create("https://login.yahoo.com/config/login");
        request.Method = "POST";
        request.ContentType = "application/x-www-form-urlencoded";

        StreamWriter writer = new StreamWriter(request.GetRequestStream());
        writer.Write(input);
        writer.Close();

        StreamReader reader = new StreamReader(request.GetResponse().GetResponseStream());

        string x = reader.ReadToEnd();

        Console.Read();
    }
+5
source share
6 answers

When you look at the html source of the yahoo page, you will notice that there are many hidden fields

image showing the hidden fields of the form

which are used to protect the user, for example, from CSRF

, yahoo, -CSRF, . javascript, . , - , .

, , , .

+5

, , , . , OpenID OAuth.

Yahoo

+2

. , , , cookie, , . HttpWebRequest?

+1

- . -, . VB6, , , webbrowser, - , , .

, , captcha, , .

0

html-, yahoo . , html "[Login]" , http-.

html, yahoo, HIDDEN , , , . HIDDEN html , , - http. .Net Framework

, :)

0

Here is a link that explains OAuth workflows and code. Beyond Yahoo, Twitter is a good site to learn. Some of the code in the link uses Twitter. Please note that OAuth 2.0 is missing.

http://www.codeproject.com/Articles/131978/Demystifying-OAuth

0
source

All Articles