Ejemplo n.º 1
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();
            }
        }
Ejemplo n.º 2
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();
            }
        }