Skip to content

Instantly share code, notes, and snippets.

@qwerty2501
Created June 17, 2012 04:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save qwerty2501/2943430 to your computer and use it in GitHub Desktop.
Save qwerty2501/2943430 to your computer and use it in GitHub Desktop.
C#でのニコ動ログイン(動く)
public bool DeepLogin()
{
bool login = false;//ログイン成否
HttpWebRequest req = WebRequest.CreateHttp(new Uri(deepLoginUrl, UriKind.Absolute));
req.Method = "POST";
req.ContentType = "application/x-www-form-urlencoded";
req.CookieContainer = App.ViewModel.UserSetting.cc;
using (StreamWriter sw = new StreamWriter(req.GetRequestStreamAsync().GetAwaiter().GetResult()))
{
sw.WriteAsync(string.Format("mail={0}&password={1}", App.ViewModel.UserSetting.UserID, App.ViewModel.UserSetting.UserPass)).GetAwaiter().GetResult();
sw.FlushAsync().GetAwaiter().GetResult();
sw.Dispose();
}
HttpWebResponse res = req.GetResponseAsync().GetAwaiter().GetResult() as HttpWebResponse;
if (res != null && res.StatusCode == HttpStatusCode.OK)
{
if (res.ResponseUri.Host != "secure.nicovideo.jp")
login = true;
}
return login;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment