以下代码未登录 yahoo。应该如何重写?
(当然,“用户名”和“密码”将替换为我的实际帐户名和密码。)
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();
}