Exemple #1
0
        public static string Comment(string mid, string ouid, string commentstr, string refer, CookieContainer weibocc, WebProxy proxy)
        {
            string commenturl = "http://weibo.com/aj/v6/comment/add?ajwvr=6&__rnd=" + HttpHelper1.GetTicks();

            commentstr = System.Web.HttpUtility.UrlEncode(commentstr.Trim());
            commentstr = commentstr.Trim().Replace("+", "%20");

            string commentpoststr = "act=post&mid=" + mid + "&uid=" + ouid + "&forward=0&isroot=0&content=" + commentstr + "&location=&module=scommlist&group_source=&pdetail=&_t=0";
            string commentresult  = HttpHelper1.SendDataByPost(commenturl, commentpoststr, refer, ref weibocc, proxy);

            if (commentresult.Contains("{\"code\":\"100001\""))
            {
                //Thread.Sleep(10 * 60 * 1000);//如果第一次评论就提示发布相同内容,则将线程停顿10分钟
                return(commentresult);//如果第一次评论就报错,一般认为是mid为空,直接返回不处理
            }

            if (commentresult.Contains("{\"code\":\"100027\""))
            {
                //需要输入验证码
                string retcode = "";
                string vcode   = "";

                while (retcode == "")
                {
                    while (vcode == "" || vcode == "IERROR" || vcode == "ERROR")
                    {
                        vcode = HttpHelper1.AutoGetVcode(weibocc);
                    }
                    retcode = WeiboHandler.GetVcodeRetcode(vcode, refer, weibocc);
                    if (retcode == "")
                    {
                        vcode = "";
                    }
                }//拿到验证码,并验证通过,通不过死循环

                commentpoststr = commentpoststr + "&retcode=" + retcode;
                commentresult  = HttpHelper1.SendDataByPost(commenturl, commentpoststr, refer, ref weibocc, proxy);//再次发送评论
            }
            return(commentresult);
        }