/// <summary> /// 点赞功能 /// </summary> /// <param name="wbLogin"></param> /// <param name="yOrN">是点赞,还是取消赞</param> /// <returns></returns> public int Like(WeiboLogin wbLogin, bool yOrN) { if (IsLike == yOrN) { return(-2); } try { TimeSpan ts = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0); //这个是点赞的接口 string url = "https://weibo.com/aj/v6/like/add?ajwvr=6&__rnd=" + (int)ts.TotalSeconds + "000"; //这个是评论的接口 //string url = "https://weibo.com/aj/v6/comment/add?ajwvr=6&__rnd=" + (int)ts.TotalSeconds + "000"; //这个是点赞的提交字符串 string postStr = "location=" + WBPage.Location + "&version=mini&qid=heart&mid=" + ID + "&loc=profile&cuslike=1&_t=0"; //这个是评论的提交字符串,转发把forward改成1 //string postStr = "act=post&mid=" + ID + "&uid=3166169725&forward=0&isroot=0&content=helloworld!&location=" + WBPage.Location + "&module=scommlist&group_source=&pdetail=1005056399610336&_t=0"; string responseStr = HttpHelper.Post(url, WBPage.Url, wbLogin.MyCookies, postStr); //System.Windows.Forms.MessageBox.Show(url); //System.Windows.Forms.MessageBox.Show(postStr); //System.Windows.Forms.MessageBox.Show(responseStr); ResponseJson responseJson = JsonConvert.DeserializeObject <ResponseJson>(responseStr); return(responseJson.data.isDel); } catch { return(-1); } }
public MonitorTimer(WeiboLogin wbLogin, string uid) { this.wbLogin = wbLogin; this.uid = uid; string html = wbLogin.Get("https://weibo.com/" + uid + "?is_all=1"); oldPage = new WeiboPage(html); }
public FormPIN(WeiboLogin wb, Image pinImage) { InitializeComponent(); picPIN.Image = pinImage; this.wb = wb; //this.Owner = f; this.StartPosition = FormStartPosition.CenterScreen; //this.Location = new Point(this.Owner.Location.X + 10, this.Owner.Location.Y + 10); }
/// <summary> /// 点赞功能 /// </summary> /// <param name="wbLogin"></param> /// <param name="yOrN">是点赞,还是取消赞</param> /// <returns></returns> public int Like(WeiboLogin wbLogin, bool yOrN) { if (IsLike == yOrN) { return(-2); } try { string url = "http://weibo.com/aj/v6/like/add?ajwvr=6"; string postStr = "location=" + WBPage.Location + "&version=mini&qid=heart&mid=" + ID + "&loc=profile"; string responseStr = HttpHelper.Post(url, WBPage.Url, wbLogin.MyCookies, postStr); ResponseJson responseJson = JsonConvert.DeserializeObject <ResponseJson>(responseStr); return(responseJson.data.isDel); } catch { return(-1); } }
private void bgwLogin_DoWork(object sender, DoWorkEventArgs e) { isLogin = false; SwitchControl(false); string result = "登陆失败,未知错误"; try { // 模拟登陆 wbLogin = new WeiboLogin(txtUsername.Text, txtPassword.Text, chkForcedpin.Checked); Image pinImage = wbLogin.Start(); if (pinImage != null) { Form formPIN = new FormPIN(wbLogin, pinImage); if (formPIN.ShowDialog() == DialogResult.OK) { result = wbLogin.End((string)formPIN.Tag); } else { result = "用户没有输入验证码,请重新登陆"; } } else { result = wbLogin.End(null); } } catch (Exception ex) { result = ex.Message; } // 对登陆结果进行判断并处理 if (result == "0") { // 开启timer监控页面 isLogin = true; SwitchControl(!isLogin); SetText(rtbOutput, "模拟登陆成功" + Environment.NewLine); try { mTimer = new MonitorTimer(wbLogin, txtUID.Text.Trim()); mTimer.Interval = Convert.ToInt32(txtInterval.Text.Trim()) * 1000; mTimer.Elapsed += new System.Timers.ElapsedEventHandler(mTimer_Elapsed); mTimer.Start(); AppendText(rtbOutput, "开始监控,刷新间隔:" + txtInterval.Text.Trim() + " s" + Environment.NewLine); } catch (Exception ex) { MessageBox.Show(ex.Message, "提示"); SwitchControl(!isLogin); } } else if (result == "2070") { MessageBox.Show("验证码错误,请重新登陆", "提示"); } else if (result == "101&") { MessageBox.Show("密码错误,请重新登陆", "提示"); } else if (result == "4049") { MessageBox.Show("验证码为空,请重新登陆。(如果你没有输入验证码,请选中强制验证码进行登录)", "提示"); } else { MessageBox.Show(result, "提示"); } SwitchControl(!isLogin); }