예제 #1
0
        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);
        }
예제 #2
0
        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();
            }
        }
예제 #3
0
        private string GetUserSession(ICookieGetter cookieGetter)
        {
            Cookie cookie = cookieGetter.GetCookie(new Uri(CookieUrl), CookieKey);

            if (cookie != null)
            {
                _cookieValue = cookie.Value;
            }
            else
            {
                _cookieValue = "";
            }

            return(_cookieValue);
        }
예제 #4
0
		/// <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;
        }
예제 #8
0
        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();
            }

        }