コード例 #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
ファイル: LoginManager.cs プロジェクト: nico-lab/niconama-ocv
		/// <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;
		}
コード例 #5
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;
        }
コード例 #6
0
        private string GetUserSession(ICookieGetter cookieGetter)
        {
            Cookie cookie = cookieGetter.GetCookie(new Uri(CookieUrl), CookieKey);

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

            return _cookieValue;
        }
コード例 #7
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);
                    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();
            }

        }