예제 #1
0
 /// <summary>
 /// 发微博
 /// </summary>
 /// <param name="wbLogin"></param>
 /// <param name="yOrN">是点赞,还是取消赞</param>
 /// <returns></returns>
 public int SendWeibo(WeiboLogin wbLogin)
 {
     try
     {
         TimeSpan ts      = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0);
         string   url     = "http://weibo.com/aj/mblog/add?ajwvr=6&__rnd=" + Convert.ToInt64(ts.TotalMilliseconds);
         string   postStr = "location=v6_content_home&text={0}&appkey=&style_type=1&pic_id=&pdetail=&rank=0&rankid=&module=stissue&pub_source=main_&pub_type=dialog&_t=0";
         postStr = string.Format(postStr, GetWeiboContent());
         string       refer        = "http://weibo.com/" + this.WeiboID + "/home?topnav=1&wvr=6";
         string       responseStr  = HttpHelper.Post(url, refer, wbLogin.MyCookies, postStr);
         ResponseJson responseJson = JsonConvert.DeserializeObject <ResponseJson>(responseStr);
         return(responseJson.data.isDel);
     }
     catch
     {
         return(-1);
     }
 }
예제 #2
0
        private void bgwLogin_DoWork(object sender, DoWorkEventArgs e)
        {
            SetEnabled(txtUsername, false);
            SetEnabled(txtPassword, false);
            SetEnabled(txtOutput, false);
            SetEnabled(btnLogin, false);
            string result = "登陆失败,未知错误";

            try
            {
                wb = new WeiboLogin(txtUsername.Text, txtPassword.Text, chkForcedpin.Checked);
                Image pinImage = wb.Start();
                if (pinImage != null)
                {
                    Form formPIN = new FormPIN(wb, pinImage);
                    if (formPIN.ShowDialog() == DialogResult.OK)
                    {
                        result = wb.End((string)formPIN.Tag);
                        string html = wb.Get("http://weibo.com/5237923337/");
                        SetText(txtOutput, html);
                    }
                    else
                    {
                        result = "用户没有输入验证码,请重新登陆";
                    }
                }
                else
                {
                    result = wb.End();
                    string html = wb.Get("http://weibo.com/5237923337/");
                    SetText(txtOutput, html);
                }
            }
            catch (Exception ex)
            {
                result = ex.Message;
            }

            //对登陆结果进行判断并处理

            if (result == "0")
            {
                MessageBox.Show("登陆成功!");
            }
            else if (result == "2070")
            {
                MessageBox.Show("验证码错误,请重新登陆", "提示");
            }
            else if (result == "101&")
            {
                MessageBox.Show("密码错误,请重新登陆", "提示");
            }
            else if (result == "4049")
            {
                MessageBox.Show("验证码为空,请重新登陆(如果你没有输入验证码,请选中强制验证码进行登录)", "提示");
            }
            else
            {
                MessageBox.Show(result, "提示");
            }

            SetEnabled(txtUsername, true);
            SetEnabled(txtPassword, true);
            SetEnabled(txtOutput, true);
            SetEnabled(btnLogin, true);
        }
예제 #3
0
 public FormPIN(WeiboLogin wb, Image pinImage)
 {
     InitializeComponent();
     picPIN.Image = pinImage;
     this.wb      = wb;
 }