Example #1
0
        /// <summary>
        /// send a post
        /// </summary>
        /// <param name="client">A <see cref="IS1Client"/> WebClient</param>
        /// <param name="verify">verify string retreive from <see cref="UserExtension.GetVerifyString"/></param>
        /// <param name="reletivePostUrl">something like post.php?action=reply&amp;fid=75&amp;tid=900385</param>
        /// <param name="content">post content</param>
        /// <param name="signature"></param>
        /// <param name="title">post title</param>
        /// <returns></returns>
        public static async Task <UserErrorTypes> ReplyOld(this IS1Client client, string verify, string reletivePostUrl, string content, string signature = "", string title = "")
        {
            AddConstParam(client);

            client.AddPostParam("verify", verify);
            client.AddPostParam("atc_content", content + signature);
            client.AddPostParam("atc_title", title);

            var result = await client.PostDataTaskAsync(new Uri(SiteBase + reletivePostUrl));

            try
            {
                var    root  = XDocument.Parse(result).Root;
                string error = root.Value.ToLower();
                System.Diagnostics.Debug.WriteLine(error);

                if (error.StartsWith("success"))
                {
                    return(UserErrorTypes.Success);
                }
                else if (error.Contains("非法请求"))
                {
                    return(UserErrorTypes.InvalidVerify);
                }
                else
                {
                    throw new S1UserException(error, UserErrorTypes.Unknown);
                }
            }
            catch (System.Xml.XmlException)
            {
                System.Diagnostics.Debug.WriteLine(result);
                throw new NullReferenceException();
            }
        }
Example #2
0
        /// <summary>
        /// send a post
        /// </summary>
        /// <param name="client">A <see cref="IS1Client"/> WebClient</param>
        /// <param name="verify">formhash from server</param>
        /// <param name="reletivePostUrl">something like post.php?action=reply&amp;fid=75&amp;tid=900385</param>
        /// <param name="content">post content</param>
        /// <param name="signature"></param>
        /// <param name="title">post title</param>
        /// <returns></returns>
        public static async Task <UserErrorTypes> Reply(this IS1Client client, string verify, string reletivePostUrl, string content, string signature = "", string title = "")
        {
            //AddConstParam(client);
            //client.AddPostParam("replysubmit", "true");
            client.AddPostParam("mobiletype", "3");
            client.AddPostParam("formhash", verify);
            client.AddPostParam("message", content + signature);

            var result = await client.PostDataTaskAsync(new Uri(SiteBase + reletivePostUrl));

            try
            {
                var data = DZHeader.FromJson(result);
                if (data.Message.Messageval != "post_reply_succeed")
                {
                    throw new S1UserException(data.Message.Messagestr, UserErrorTypes.Unknown);
                }
                return(UserErrorTypes.Success);
            }
            catch (System.Xml.XmlException)
            {
                System.Diagnostics.Debug.WriteLine(result);
                throw new NullReferenceException();
            }
        }
Example #3
0
        public static async Task <bool> Logout(this IS1Client client, string formhash)
        {
            var result = await client.PostDataTaskAsync(new Uri(string.Format("{0}&formhash={1}", logoutUrl, formhash)));

            var user = DZUser.FromJson(result);

            return(user.Message.Messageval == loginSucceed || user.Message.Messageval == loginSucceedMobile);
        }
Example #4
0
        public static async Task <UserVariables> Login(this IS1Client client, string account, string pass, int loginType = 0)
        {
            client.AddPostParam(stepKey, stepValue);
            //client.AddPostParam(loginTypeKey, loginType);
            client.AddPostParam(userKey, account);
            client.AddPostParam(passKey, pass);
            var result = await client.PostDataTaskAsync(new Uri(loginUrl));

            var user = DZUser.FromJson(result);

            if (user.Message.Messageval != loginSucceed &&
                user.Message.Messageval != loginSucceedMobile)
            {
                throw new LoginException(user.Message.Messagestr, account, pass);
            }
            return(user.Variables);
        }
Example #5
0
        public static async Task <UserErrorTypes> AddToFavorite(this IS1Client client, string verify, string tid)
        {
            client.AddPostParam("favoritesubmit", "true");
            client.AddPostParam("formhash", verify);

            var result = await client.PostDataTaskAsync(new Uri(SiteBase + string.Format("index.php?module=favthread&id={0}", tid)));

            try
            {
                var data = DZHeader.FromJson(result);
                throw new S1UserException(data.Message.Messagestr);
            }
            catch (System.Xml.XmlException)
            {
                System.Diagnostics.Debug.WriteLine(result);
                throw new NullReferenceException();
            }
        }