Esempio n. 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="server"></param>
        /// <param name="cc"></param>
        /// <returns></returns>
        /// <exception cref="ParseException"></exception>
        public static async Task <UserInfoBase> GetCurrentUserInfo(IDataServer server, CookieContainer cc)
        {
            var url     = "https://mixer.com/api/v1/users/current";
            var headers = new Dictionary <string, string>
            {
            };
            string res = await server.GetWithNoThrowAsync(url, headers, cc);

            UserInfoBase infoBase;

            if (res.Contains("Unauthorized"))
            {
                //{"errorCode":24317,"errorMessage":"Unauthorized"}
                infoBase = new AnonymousUserInfo();
            }
            else
            {
                var obj = Tools.Deserialize <Low.CurrentUser.RootObject>(res);
                infoBase = new CurrentUser(obj);
            }
            return(infoBase);
        }