예제 #1
0
파일: BuAPI.cs 프로젝트: olenheim/Bitunion
        //回复帖子
        public static async Task <bool> ReplyPost(string tid, string msg)
        {
            //增加消息尾巴
            if (BuSetting.ShowTail)
            {
                msg += "\r\n[i]" + BuSetting.TailMsg + "[/i]";
            }

            JObject staff = new JObject();

            staff.Add(new JProperty("action", "newreply"));
            staff.Add(new JProperty("username", Uri.EscapeDataString(_name)));
            staff.Add(new JProperty("session", _session));
            staff.Add(new JProperty("tid", tid));
            staff.Add(new JProperty("message", Uri.EscapeDataString(msg)));
            staff.Add(new JProperty("attachment", 1));
            string Context = staff.ToString();

            Stream response = await _httphelper.PostFormAsync(BuSetting.URL + "bu_newpost.php", Context);

            if (response == null || response.Length == 0)
            {
                return(false);
            }

            JObject jsonret = null;

            if (!StreamToJobjAndCheckState(response, ref jsonret))
            {
                if (jsonret["msg"].ToString() == "IP+logged" && await Login(_name, _password))
                {
                    return(await ReplyPost(tid, msg));
                }
                else
                {
                    return(false);
                }
            }

            return(true);
        }