我想知道如何允许用户使用 WebClient 类登录 xbox.com。到目前为止,我已经获得了以下代码,但出现了不正确的密码/用户组合错误。
NameValueCollection formData = new NameValueCollection();
formData["login"] = "username";
formData["passwd"] = "pass";
string url = "https://login.live.com/ppsecure/post.srf?wa=wsignin1.0&rpsnv=11&ct=1294985876&rver=6.0.5286.0&wp=MBI&wreply=https://live.xbox.com:443/xweb/live/passport/setCookies.ashx%3Frru%3Dhttp%253a%252f%252fwww.xbox.com%252fen-US%252f&lc=1033&cb=reason%3D0%26returnUrl%3Dhttp%253a%252f%252fwww.xbox.com%252fen-US%252f&id=66262&bk=1294986379";
WebClient webClient = new WebClient();
byte[] responseBytes = webClient.UploadValues(url, "POST", formData);
string response = Encoding.UTF8.GetString(responseBytes);
Response.Write(response);
我是否需要执行一些 javascript 来验证用户身份?另外,请告诉我应该如何处理 cookie。我不熟悉 CookieContainers。非常感谢。