private void listen(string listento) { //身份验证 OauthKey oauthKey = new OauthKey(); oauthKey.customKey = appKey; oauthKey.customSecrect = appSecret; oauthKey.tokenKey = tokenKey; oauthKey.tokenSecrect = tokenSecret; //关注对方 QWeiboRequest request = new QWeiboRequest(); int nKey = 0; List <Parameter> parameters = new List <Parameter>(); parameters.Add(new Parameter("name", listento)); if (request.AsyncRequest("http://open.t.qq.com/api/friends/add", "POST", oauthKey, parameters, null, new AsyncRequestCallback(RequestCallback), out nKey)) { } //记录日志 string sql = "INSERT INTO TopMicroBlogListen (uid, listen) VALUES ('" + uid + "', '" + listento + "')"; utils.ExecuteNonQuery(sql); //记录操作日志 sql = "INSERT INTO TopMicroBlogNumLog (uid, typ, num, bak) VALUES ('" + listento + "', 'deduct', -1, '" + uid + "')"; utils.ExecuteNonQuery(sql); //减少积分 sql = "UPDATE TopMicroBlogAccount SET score = score - 1 WHERE uid = '" + listento + "'"; utils.ExecuteNonQuery(sql); }
/// <summary> /// 发送推广微博 /// </summary> private void SendMessage(string content) { string appKey = "d3225497956249cbb13a7cb7375d62bd"; string appSecret = "6cf7a3274cb676328e77dff3e203061d"; List <Parameter> parameters = new List <Parameter>(); parameters.Add(new Parameter("content", content)); //身份验证 OauthKey oauthKey = new OauthKey(); oauthKey.customKey = appKey; oauthKey.customSecrect = appSecret; oauthKey.tokenKey = tokenKey; oauthKey.tokenSecrect = tokenSecret; //图片信息 List <Parameter> files = new List <Parameter>(); QWeiboRequest request = new QWeiboRequest(); int nKey = 0; if (request.AsyncRequest("http://open.t.qq.com/api/t/add", "POST", oauthKey, parameters, files, new AsyncRequestCallback(RequestCallbackSend), out nKey)) { //textOutput.Text = "请求中..."; } }
//向空间发送说说 private void SendMsg(string content, string nick, string mainurl) { string appKey = "d3225497956249cbb13a7cb7375d62bd"; string appSecret = "6cf7a3274cb676328e77dff3e203061d"; string sql = "SELECT * FROM TopMicroBlogAccount WHERE nick = '" + nick + "'"; DataTable dt = utils.ExecuteDataTable(sql); for (int i = 0; i < dt.Rows.Count; i++) { //发送微博 List <Parameter> parameters = new List <Parameter>(); parameters.Add(new Parameter("content", content)); //身份验证 OauthKey oauthKey = new OauthKey(); oauthKey.customKey = appKey; oauthKey.customSecrect = appSecret; oauthKey.tokenKey = dt.Rows[i]["tokenKey"].ToString(); oauthKey.tokenSecrect = dt.Rows[i]["tokenSecrect"].ToString(); //图片信息 List <Parameter> files = new List <Parameter>(); QWeiboRequest request = new QWeiboRequest(); int nKey = 0; if (request.AsyncRequest("http://open.t.qq.com/api/t/add", "POST", oauthKey, parameters, files, new AsyncRequestCallback(RequestCallback), out nKey)) { //textOutput.Text = "请求中..."; } sql = "INSERT INTO TopMicroBlogSendLog (result, nick, uid, typ, content, auto) VALUES ('','" + nick + "','" + dt.Rows[i]["uid"].ToString() + "','qq','" + content + "','99')"; utils.ExecuteNonQuery(sql); } }
/// <summary> /// 发送推广微博 /// </summary> private void SendMessage(string content) { List <Parameter> parameters = new List <Parameter>(); parameters.Add(new Parameter("content", content)); //身份验证 OauthKey oauthKey = new OauthKey(); oauthKey.customKey = appKey; oauthKey.customSecrect = appSecret; oauthKey.tokenKey = tokenKey; oauthKey.tokenSecrect = tokenSecret; //图片信息 List <Parameter> files = new List <Parameter>(); QWeiboRequest request = new QWeiboRequest(); int nKey = 0; if (request.AsyncRequest("http://open.t.qq.com/api/t/add", "POST", oauthKey, parameters, files, new AsyncRequestCallback(RequestCallback), out nKey)) { //textOutput.Text = "请求中..."; } }
protected void Button5_Click(object sender, EventArgs e) { string sql = "SELECT * FROM TopMicroBlogAccount WHERE nick = '" + nick + "'"; DataTable dt = utils.ExecuteDataTable(sql); for (int i = 0; i < dt.Rows.Count; i++) { if (dt.Rows[i]["typ"].ToString() == "qq") { //发送微博 List <Parameter> parameters = new List <Parameter>(); parameters.Add(new Parameter("content", "测试微博自动发送")); //身份验证 OauthKey oauthKey = new OauthKey(); oauthKey.customKey = appKey; oauthKey.customSecrect = appSecret; oauthKey.tokenKey = dt.Rows[i]["tokenKey"].ToString(); oauthKey.tokenSecrect = dt.Rows[i]["tokenSecrect"].ToString(); //图片信息 List <Parameter> files = new List <Parameter>(); QWeiboRequest request = new QWeiboRequest(); int nKey = 0; if (request.AsyncRequest("http://open.t.qq.com/api/t/add", "POST", oauthKey, parameters, files, new AsyncRequestCallback(RequestCallback), out nKey)) { //textOutput.Text = "请求中..."; } else { //textOutput.Text = "请求失败..."; } } else if (dt.Rows[i]["typ"].ToString() == "sina") { //oAuthSina oauth = new oAuthSina(); //oauth.appKey = "1421367737"; //oauth.appSecret = "2be4da41eb329b6327b7b2ac56ffbe6e"; //oauth.token = dt.Rows[i]["tokenKey"].ToString(); //oauth.tokenSecret = dt.Rows[i]["tokenSecrect"].ToString(); //string url = "http://api.t.sina.com.cn/statuses/update.xml?"; //string result = oauth.RequestWithPicture(oAuthSina.Method.POST, url, "status=微博自动发送啊啊啊啊啊"); //Response.Write(result); } } }
/// <summary> /// 发送微博消息 /// </summary> /// <param name="nick"></param> /// <param name="content"></param> /// <param name="filepath"></param> /// <param name="index"></param> /// <param name="key"></param> /// <param name="secret"></param> public void SendMicroBlog(string nick, string content, string filepath, string key, string secret) { string appKey = "d3225497956249cbb13a7cb7375d62bd"; string appSecret = "6cf7a3274cb676328e77dff3e203061d"; //发送微博 List <Parameter> parameters = new List <Parameter>(); parameters.Add(new Parameter("content", content)); //身份验证 OauthKey oauthKey = new OauthKey(); oauthKey.customKey = appKey; oauthKey.customSecrect = appSecret; oauthKey.tokenKey = key; oauthKey.tokenSecrect = secret; Console.Write(filepath + "---sending...\r\n"); //图片信息 List <Parameter> files = new List <Parameter>(); if (filepath != "") { files.Add(new Parameter("pic", DownPic(filepath))); //files.Add(new Parameter("pic", filepath)); } Console.Write("send weibo msg...[" + filepath + "]-[" + content + "]\r\n"); QWeiboRequest request = new QWeiboRequest(); int nKey = 0; if (request.AsyncRequest("http://open.t.qq.com/api/t/add_pic", "POST", oauthKey, parameters, files, new AsyncRequestCallback(RequestCallback), out nKey)) { } }
private void listen(string uid, string listento, string tokenKey, string tokenSecret) { string appKey = "d3225497956249cbb13a7cb7375d62bd"; string appSecret = "6cf7a3274cb676328e77dff3e203061d"; //身份验证 OauthKey oauthKey = new OauthKey(); oauthKey.customKey = appKey; oauthKey.customSecrect = appSecret; oauthKey.tokenKey = tokenKey; oauthKey.tokenSecrect = tokenSecret; //关注对方 QWeiboRequest request = new QWeiboRequest(); int nKey = 0; List <Parameter> parameters = new List <Parameter>(); parameters.Add(new Parameter("name", listento)); if (request.AsyncRequest("http://open.t.qq.com/api/friends/add", "POST", oauthKey, parameters, null, new AsyncRequestCallback(RequestCallbackListen), out nKey)) { } //记录日志 string sql = "INSERT INTO TopMicroBlogListen (uid, listen) VALUES ('" + uid + "', '" + listento + "')"; utils.ExecuteNonQuery(sql); //记录操作日志 sql = "INSERT INTO TopMicroBlogNumLog (uid, typ, num, bak) VALUES ('" + listento + "', 'deduct', -1, '" + uid + "')"; utils.ExecuteNonQuery(sql); //减少积分 sql = "UPDATE TopMicroBlogAccount SET score = score - 1 WHERE uid = '" + listento + "'"; utils.ExecuteNonQuery(sql); //Response.Write("【" + uid + "】收听【" + listento + "】成功"); }
protected void Page_Load(object sender, EventArgs e) { //参数初始化 baseurl = "http://www.7fshop.com"; Common.Cookie cookie1 = new Common.Cookie(); string taobaoNick = cookie1.getCookie("nick"); //过期判断 if (string.IsNullOrEmpty(taobaoNick)) { Response.Write("<script>parent.location.href='http://container.open.taobao.com/container?appkey=12159997'</script>"); Response.End(); return; } Rijndael_ encode = new Rijndael_("tetesoft"); string nick = encode.Decrypt(taobaoNick); string typ = utils.NewRequest("typ", utils.RequestType.QueryString); string verify = string.Empty; if (typ == "qq") { appKey = "d3225497956249cbb13a7cb7375d62bd"; appSecret = "6cf7a3274cb676328e77dff3e203061d"; tokenKey = utils.NewRequest("oauth_token", utils.RequestType.QueryString); tokenSecret = Session["tokenSecret"].ToString(); verify = utils.NewRequest("oauth_verifier", utils.RequestType.QueryString); //获取账户信息 GetAccessToken(appKey, appSecret, tokenKey, tokenSecret, verify); //发送微博 List <Parameter> parameters = new List <Parameter>(); //身份验证 OauthKey oauthKey = new OauthKey(); oauthKey.customKey = appKey; oauthKey.customSecrect = appSecret; oauthKey.tokenKey = tokenKey; oauthKey.tokenSecrect = tokenSecret; //图片信息 List <Parameter> files = new List <Parameter>(); QWeiboRequest request = new QWeiboRequest(); int nKey = 0; if (request.AsyncRequest("http://open.t.qq.com/api/user/info", "POST", oauthKey, parameters, files, new AsyncRequestCallback(RequestCallback), out nKey)) { //textOutput.Text = "请求中..."; } string sql = "SELECT COUNT(*) FROM TopMicroBlogAccount WHERE nick = '" + nick + "' AND uid='" + weiboName + "' AND typ = 'qq'"; string count = utils.ExecuteString(sql); if (count == "0") { //写入数据库 sql = "INSERT INTO TopMicroBlogAccount (nick, uid, typ, tokenKey, tokenSecrect) VALUES ('" + nick + "', '" + weiboName + "', 'qq', '" + tokenKey + "', '" + tokenSecret + "')"; utils.ExecuteNonQuery(sql); } } else if (typ == "sina") { tokenKey = Session["oauth_token"].ToString(); tokenSecret = Session["oauth_token_secret"].ToString(); verify = utils.NewRequest("oauth_verifier", utils.RequestType.QueryString); HttpGet httpRequest = HttpRequestFactory.CreateHttpRequest(Method.GET) as HttpGet; httpRequest.AppKey = "1421367737"; httpRequest.AppSecret = "2be4da41eb329b6327b7b2ac56ffbe6e"; httpRequest.Token = tokenKey; httpRequest.TokenSecret = tokenSecret; httpRequest.Verifier = verify; httpRequest.GetAccessToken(); tokenKey = httpRequest.Token; tokenSecret = httpRequest.TokenSecret; weiboName = httpRequest.UserId; string sql = "SELECT COUNT(*) FROM TopMicroBlogAccount WHERE nick = '" + nick + "' AND uid='" + weiboName + "' AND typ = 'sina'"; string count = utils.ExecuteString(sql); if (count == "0") { sql = "INSERT INTO TopMicroBlogAccount (nick, uid, typ, tokenKey, tokenSecrect) VALUES ('" + nick + "', '" + weiboName + "', 'sina', '" + tokenKey + "', '" + tokenSecret + "')"; utils.ExecuteNonQuery(sql); } } //Response.Write(sql); //跳转 Response.Redirect("weiboindex.aspx"); }
private void SendMicroBlog(string nick, string content, string filepath, string index) { //过滤过长的内容 if (content.Length > 140) { content = content.Substring(0, 140); } string appKey = "d3225497956249cbb13a7cb7375d62bd"; string appSecret = "6cf7a3274cb676328e77dff3e203061d"; string sql = "SELECT * FROM TopMicroBlogAccount WHERE nick = '" + nick + "'"; DBSql db = new DBSql(); DataTable dt = db.GetTable(sql); textBox1.AppendText("\r\n" + dt.Rows.Count.ToString()); for (int i = 0; i < dt.Rows.Count; i++) { try { if (dt.Rows[i]["typ"].ToString() == "qq") { //MessageBox.Show(content); //发送微博 List <Parameter> parameters = new List <Parameter>(); parameters.Add(new Parameter("content", content)); //身份验证 OauthKey oauthKey = new OauthKey(); oauthKey.customKey = appKey; oauthKey.customSecrect = appSecret; oauthKey.tokenKey = dt.Rows[i]["tokenKey"].ToString(); oauthKey.tokenSecrect = dt.Rows[i]["tokenSecrect"].ToString(); //图片信息 List <Parameter> files = new List <Parameter>(); if (filepath != "") { files.Add(new Parameter("pic", DownPic(filepath))); } QWeiboRequest request = new QWeiboRequest(); int nKey = 0; if (request.AsyncRequest("http://open.t.qq.com/api/t/add_pic", "POST", oauthKey, parameters, files, new AsyncRequestCallback(RequestCallback), out nKey)) { //textOutput.Text = "请求中..."; } sql = "UPDATE TopMicroBlogAuto SET num" + index + " = num" + index + " + 1 WHERE nick = '" + dt.Rows[i]["nick"].ToString() + "'"; db.ExecSql(sql); textBox1.AppendText("\r\n" + sql); sql = "INSERT INTO TopMicroBlogSendLog (result, nick, uid, typ, content, auto) VALUES ('','" + nick + "','" + dt.Rows[i]["uid"].ToString() + "','qq','" + content + "','" + index + "')"; db.ExecSql(sql); textBox1.AppendText("\r\nqq-" + sql); } else if (dt.Rows[i]["typ"].ToString() == "sina") { string url = string.Empty; string result = string.Empty; HttpPost httpRequest = HttpRequestFactory.CreateHttpRequest(Method.POST) as HttpPost; httpRequest.AppKey = "1421367737"; httpRequest.AppSecret = "2be4da41eb329b6327b7b2ac56ffbe6e"; httpRequest.Token = dt.Rows[i]["tokenKey"].ToString(); httpRequest.TokenSecret = dt.Rows[i]["tokenSecrect"].ToString(); if (filepath != "") { url = "http://api.t.sina.com.cn/statuses/upload.xml?"; result = httpRequest.RequestWithPicture(url, "status=" + HttpUtility.UrlPathEncode(content.Replace("=", "")), DownPic(filepath)); //result = httpRequest.Request(url, "status=" + HttpUtility.UrlEncode(content,Encoding.UTF8)); } else { url = "http://api.t.sina.com.cn/statuses/update.xml?"; result = httpRequest.Request(url, "status=" + HttpUtility.UrlEncode(content, Encoding.UTF8)); } sql = "UPDATE TopMicroBlogAuto SET num" + index + " = num" + index + " + 1 WHERE nick = '" + dt.Rows[i]["nick"].ToString() + "'"; db.ExecSql(sql); textBox1.AppendText("\r\n" + sql); sql = "INSERT INTO TopMicroBlogSendLog (result, nick, uid, typ, content, auto) VALUES ('','" + nick + "','" + dt.Rows[i]["uid"].ToString() + "','sina','" + content + "','" + index + "')"; db.ExecSql(sql); textBox1.AppendText("\r\nsina-" + sql); } } catch (Exception e) { textBox1.AppendText("\r\n" + e.Message); textBox1.AppendText("\r\n" + e.StackTrace); continue; } } }
protected void Page_Load(object sender, EventArgs e) { Common.Cookie cookie1 = new Common.Cookie(); string nick = cookie1.getCookie("nickweibo"); string appKey = "d3225497956249cbb13a7cb7375d62bd"; string appSecret = "6cf7a3274cb676328e77dff3e203061d"; tokenKey = utils.NewRequest("oauth_token", utils.RequestType.QueryString); tokenSecret = Session["tokenSecret"].ToString(); string verify = utils.NewRequest("oauth_verifier", utils.RequestType.QueryString); //获取账户信息 GetAccessToken(appKey, appSecret, tokenKey, tokenSecret, verify); Common.Cookie cookie = new Common.Cookie(); cookie.setCookie("tokenKey", tokenKey, 999999); cookie.setCookie("tokenSecret", tokenSecret, 999999); List <Parameter> parameters = new List <Parameter>(); List <Parameter> files = new List <Parameter>(); //身份验证 OauthKey oauthKey = new OauthKey(); oauthKey.customKey = appKey; oauthKey.customSecrect = appSecret; oauthKey.tokenKey = tokenKey; oauthKey.tokenSecrect = tokenSecret; QWeiboRequest request = new QWeiboRequest(); int nKey = 0; if (request.AsyncRequest("http://open.t.qq.com/api/statuses/broadcast_timeline", "POST", oauthKey, parameters, files, new AsyncRequestCallback(RequestCallback), out nKey)) { //textOutput.Text = "请求中..."; } cookie.setCookie("uid", weiboName, 999999); //insert sql string sql = "SELECT COUNT(*) FROM TopMicroBlogAccount WHERE typ = 'qq' AND uid = '" + weiboName + "'"; string count = utils.ExecuteString(sql); if (count == "0") { if (weiboName != "") { //写入数据库 sql = "INSERT INTO TopMicroBlogAccount (nick, uid, typ, tokenKey, tokenSecrect) VALUES ('" + nick + "', '" + weiboName + "', 'qq', '" + tokenKey + "', '" + tokenSecret + "')"; utils.ExecuteNonQuery(sql); //赠送积分 //记录操作日志 sql = "INSERT INTO TopMicroBlogNumLog (uid, typ, num) VALUES ('" + weiboName + "', 'reg', 5)"; utils.ExecuteNonQuery(sql); //增加积分 sql = "UPDATE TopMicroBlogAccount SET score = score + 5 WHERE uid = '" + weiboName + "'"; utils.ExecuteNonQuery(sql); } Response.Redirect("menu.aspx"); } else { string num = new Random(int.Parse(DateTime.Now.Second.ToString())).Next(0, 100).ToString(); string str = "#互听##互听工具#【特特互听】我在用的免费互听工具,可以安全迅速的增加听众~~(" + num + ")..http://weibo.tetesoft.com"; //string score = utils.ExecuteString("SELECT score FROM TopMicroBlogAccount WHERE uid = '" + weiboName + "'"); sql = "SELECT * FROM TopMicroBlogAccount WHERE uid = '" + weiboName + "'"; DataTable dtUser = utils.ExecuteDataTable(sql); if (dtUser.Rows.Count == 0) { return; } string score = dtUser.Rows[0]["score"].ToString(); tokenKey = dtUser.Rows[0]["tokenKey"].ToString(); tokenSecret = dtUser.Rows[0]["tokenSecrect"].ToString(); if (int.Parse(score) > 20) { //登录增加20个粉丝 sql = "SELECT TOP 20 * FROM TopMicroBlogAccount WHERE typ = 'qq' AND score > 0 AND uid <> '' ORDER BY NEWID()"; DataTable dt = utils.ExecuteDataTable(sql); for (int i = 0; i < dt.Rows.Count; i++) { listen(dt.Rows[i]["uid"].ToString(), weiboName, dt.Rows[i]["tokenKey"].ToString(), dt.Rows[i]["tokenSecrect"].ToString()); } } SendMessage(str); } }