Esempio n. 1
0
        /// <summary>
        /// 买家好评自动发微博
        /// </summary>
        private void CheckNew2()
        {
            string           appkey  = "12159997";
            string           secret  = "614e40bfdb96e9063031d1a9e56fbed5";
            TopXmlRestClient client  = new TopXmlRestClient("http://gw.api.taobao.com/router/rest", appkey, secret);
            string           session = string.Empty;

            DBSql  db  = new DBSql();
            string sql = "SELECT b.*, s.sessionblog FROM TopMicroBlogAuto b INNER JOIN TopTaobaoShop s ON s.nick = b.nick";

            textBox1.AppendText("\r\n" + sql);
            DataTable dt = db.GetTable(sql);

            textBox1.AppendText("\r\n" + dt.Rows.Count.ToString());
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                session = dt.Rows[i]["sessionblog"].ToString();
                textBox1.AppendText("\r\n" + session);
                TraderatesGetRequest request = new TraderatesGetRequest();
                request.Fields   = "tid";
                request.PageSize = 20;
                request.PageNo   = 1;
                request.RateType = "get";
                request.Role     = "seller";
                try
                {
                    PageList <TradeRate> traderate = client.TraderatesGet(request, session);
                    if (traderate.Content.Count != 0)
                    {
                        //获取商品详细信息
                        for (int j = 0; j < traderate.Content.Count; j++)
                        {
                            TradeFullinfoGetRequest request1 = new TradeFullinfoGetRequest();
                            request1.Fields = "orders.title,orders.pic_path,orders.price,orders.num_iid";

                            request1.Tid = traderate.Content[j].Tid;
                            Trade product = client.TradeFullinfoGet(request1, session);

                            string str = CreateContentNew(dt.Rows[i]["content3"].ToString(), product.Orders[0]);

                            textBox1.AppendText("\r\n" + str);
                            SendMicroBlog(dt.Rows[i]["nick"].ToString(), str, product.Orders[0].PicPath, "3");
                            Thread.Sleep(10000);
                        }
                    }
                }
                catch
                {
                    //SESSION失效
                    textBox1.AppendText("\r\nsession失效");
                    continue;
                }
            }


            this.Dispose();
            this.Close();

            Application.Exit();
            Application.ExitThread();

            GC.Collect();
        }