private string GetUserName(ICookieGetter cookieGetter) { try { System.Net.CookieContainer container = new CookieContainer(); Cookie cookie = cookieGetter.GetCookie(new Uri(VerifyUrl), CookieKey); string res = null; if (cookie != null) { container.Add(cookie); using (var client = new System.Net.Http.HttpClient( new System.Net.Http.HttpClientHandler() { CookieContainer = container }) { Timeout = TimeSpan.FromMilliseconds(VerifyTimeout) }) res = client.GetStringAsync(VerifyUrl).Result; } if (!string.IsNullOrEmpty(res)) { System.Text.RegularExpressions.Match namem = System.Text.RegularExpressions.Regex.Match(res, VerifyRegex, System.Text.RegularExpressions.RegexOptions.Singleline); if (namem.Success) { return(namem.Groups[1].Value); } } } catch { } return(null); }
private void getUserSession(ICookieGetter cookieGetter) { System.Net.Cookie cookie = cookieGetter.GetCookie(new Uri("http://nicovideo.jp/"), "user_session"); if (cookie != null) { txtUserSession.Text = cookie.Value; } else { txtUserSession.Clear(); } }
private string GetUserSession(ICookieGetter cookieGetter) { Cookie cookie = cookieGetter.GetCookie(new Uri(CookieUrl), CookieKey); if (cookie != null) { _cookieValue = cookie.Value; } else { _cookieValue = ""; } return(_cookieValue); }
/// <summary> /// ログインする /// </summary> /// <param name="cookieGetter"></param> /// <returns></returns> public static AccountInfomation Login(ICookieGetter cookieGetter) { System.Net.Cookie cookie = cookieGetter.GetCookie(new Uri("http://www.nicovideo.jp/"), "user_session"); if (cookie == null) { Logger.Default.LogMessage(string.Format("Login failed, cookie dosen't found")); return null; } System.Net.CookieContainer container = new System.Net.CookieContainer(); container.Add(cookie); AccountInfomation accountInfomation = NicoApiSharp.AccountInfomation.GetMyAccountInfomation(container); if (accountInfomation != null) { DefaultCookies = container; return accountInfomation; } return null; }
private string GetUserName(ICookieGetter cookieGetter) { try { System.Net.CookieContainer container = new CookieContainer(); Cookie cookie = cookieGetter.GetCookie(new Uri(VerifyUrl), CookieKey); string res = null; if (cookie != null) { container.Add(cookie); using (var client = new System.Net.Http.HttpClient( new System.Net.Http.HttpClientHandler() { CookieContainer = container }) { Timeout = TimeSpan.FromMilliseconds(VerifyTimeout) }) res = client.GetStringAsync(VerifyUrl).Result; } if (!string.IsNullOrEmpty(res)) { System.Text.RegularExpressions.Match namem = System.Text.RegularExpressions.Regex.Match(res, VerifyRegex, System.Text.RegularExpressions.RegexOptions.Singleline); if (namem.Success) { return namem.Groups[1].Value; } } } catch { } return null; }
private string GetUserSession(ICookieGetter cookieGetter) { Cookie cookie = cookieGetter.GetCookie(new Uri(CookieUrl), CookieKey); if (cookie != null) { _cookieValue = cookie.Value; } else { _cookieValue = ""; } return _cookieValue; }
private string GetUserName(ICookieGetter cookieGetter) { try { System.Net.CookieContainer container = new CookieContainer(); Cookie cookie = cookieGetter.GetCookie(new Uri(VerifyUrl), CookieKey); string res = null; if(cookie != null) { container.Add(cookie); res = Utility.GetResponseText(VerifyUrl, container, VerifyTimeout); } if(!string.IsNullOrEmpty(res)) { System.Text.RegularExpressions.Match namem = System.Text.RegularExpressions.Regex.Match(res, VerifyRegex, System.Text.RegularExpressions.RegexOptions.Singleline); if(namem.Success) { return namem.Groups[1].Value; } } } catch { } return null; }
private void getUserSession(ICookieGetter cookieGetter) { System.Net.Cookie cookie = cookieGetter.GetCookie(new Uri("http://nicovideo.jp/"), "user_session"); if(cookie != null) { txtUserSession.Text = cookie.Value; } else { txtUserSession.Clear(); } }