Exemplo n.º 1
0
        /// <summary>
        /// 发布文字说说
        /// </summary>
        /// <param name="content"></param>
        /// <param name="spacecc"></param>
        /// <param name="qqhao"></param>
        /// <returns></returns>
        public static string SendShuoshuo(string content, CookieContainer spacecc, QQHao qqhao)
        {
            string url = "http://h5.qzone.qq.com/proxy/domain/taotao.qzone.qq.com/cgi-bin/emotion_cgi_publish_v6?g_tk=" + qqhao.G_tk + "&qzonetoken=" + qqhao.Token;

            string poststr    = "qzreferrer=http%3A%2F%2Fuser.qzone.qq.com%2F" + qqhao.Qqhaoma + "%2F&syn_tweet_verson=1&paramstr=1&pic_template=&richtype=&richval=&special_url=&subrichtype=&who=1&con=" + HttpUtility.UrlEncode(content) + "&feedversion=1&ver=1&ugc_right=1&to_sign=0&hostuin=" + qqhao.Qqhaoma + "&code_version=1&format=fs";
            string refer      = "http://qzone.qq.com/" + qqhao.Qqhaoma;
            string resulthtml = HttpHelper1.SendDataByPost(url, poststr, refer, ref spacecc);

            return("");
        }
Exemplo n.º 2
0
        public static string GetUserInfo(QQHao qqhao, CookieContainer spacecc)
        {
            string          url       = "http://s.web2.qq.com/api/get_self_info2?t=" + HttpHelper1.GetTicks();
            string          refer     = "http://s.web2.qq.com/proxy.html?v=20130916001&callback=1&id=1";
            string          loginurl  = "http://ptlogin4.web2.qq.com/check_sig?pttype=1&uin=3213257524&service=ptqrlogin&nodirect=0&ptsigx=iVBORw0KGgoAAAANSUhEUgAAAKUAAAClAQAAAAAVUAB3AAAACXBIWXMAAAsTAAALEwEAmpwYAAABnUlEQVRIib2XQY6EMAwEjTjkyBP4CXwMiZHmY/ATnsAxBzS93U5W2t17L4eZoXJI3LHbngg+cww3v9Z7v8rBHyVctADPXBctLdMz4wRgpEdsM47p4d7T+8J5x2ymjFjBkpb/oAs/6oA/ZzBQ6Vtwb3P5TK9fqhto5g7j3PrHj4wyUOjhReJixC8dSe8uqmCzJBBK1xoxpg4eCgiseZHABYocsFEmqdKGNZ+nKafWfZTbgzU/ZsRRVx3ER7m9VM1SHIEjRiddb21PVYtshiLT1Hx0kKpH7MpQmprC9tHMHUUczWH06qOMeOtLSzrM3fW10KxxSSuH2XkGFb6NshCyBT3tV8169NGDVlY+sV+skNccrS5ctIV4ZltXulLf9DMP5fYjejPnelXssFH07sOOLvcsPXdcVJbS9ZXDIG/TRfMOWRc5ifE2o/uZh3732LQyVki2BxttM20wYiq9o+vrojkbQe5J46TSaJnqopr7WroOXO/6Wmld1foyd5S4btpv832l3Eba/4uwD2kI43qb+zy05Y46qy7yygmwuOgXSeSL4v+A80wAAAAASUVORK5CYII=&s_url=http%3A%2F%2Fw.qq.com%2Fproxy.html%3Flogin2qq%3D1%26webqq_type%3D10&f_url=&ptlang=2052&ptredirect=100&aid=501004106&daid=164&j_later=0&low_login_hour=0&regmaster=0&pt_login_type=3&pt_aid=0&pt_aaid=16&pt_light=0&pt_3rd_aid=0";
            CookieContainer newcc     = new CookieContainer();
            string          resultstr = HttpHelper1.SendDataByGET(loginurl, ref newcc);

            string result = HttpHelper1.SendDataByGET(url, refer, ref newcc);

            return(result);
        }
Exemplo n.º 3
0
        public void StartSend(object parms)
        {
            while (true)
            {
                SetSpaceeButtonStatus(true);
                AppenSpaceCmd("开始发布说说");
                #region 登录账号并初始化
                string[] qqlist = File.ReadAllLines("qq.txt");
                foreach (string qqstr in qqlist)
                {
                    string[] qq       = qqstr.Split(',');
                    string   qqhaoma  = qq[0];
                    string   password = qq[1];
                    string   nickname = qq[2];
                    AppenSpaceCmd(qqhaoma + "发布");
                    string cookiepath = "cookie/" + qqhaoma + ".txt";
                    string token      = "";
                    if (File.Exists(cookiepath))
                    {
                        spacecc = CookieHelper.ReadCookieFromFile(cookiepath);
                        token   = QQSpaceHelper.GetToken(spacecc, qqhaoma);
                    }
                    int logintime = 0;
                    while (token == "")
                    {
                        logintime++;
                        if (logintime == 10)
                        {
                            AppenSpaceCmd("登录失败,放弃!");
                            break;
                        }
                        AppenSpaceCmd(nickname + "[" + qqhaoma + "]未登录,正在第" + logintime.ToString() + "次尝试登录!");
                        spacecc = QQSpaceHelper.Login(qqhaoma, password);
                        CookieHelper.SaveCookie(cookiepath, spacecc);
                        token = QQSpaceHelper.GetToken(spacecc, qqhaoma);
                    }
                    if (token == "")
                    {
                        continue;
                    }
                    AppenSpaceCmd(nickname + "[" + qqhaoma + "]已登录");
                    string g_tk = QQSpaceHelper.Getgtk(spacecc.GetCookieHeader(new Uri("http://qzone.qq.com")).ToString());

                    QQHao qqhao = new QQHao();
                    qqhao.Qqhaoma  = qqhaoma;
                    qqhao.Password = password;
                    qqhao.G_tk     = g_tk;
                    qqhao.Token    = token;

                    string result = QQSpaceHelper.GetUserInfo(qqhao, spacecc);
                    #endregion
                    DirectoryInfo TheFolder  = new DirectoryInfo("待发布");
                    DirectoryInfo nextFolder = TheFolder.GetDirectories()[0];//发布选品库第一条
                    AppenSpaceCmd(nickname + "[" + qqhaoma + "]发布正文:" + nextFolder.Name);
                    ArrayList imgs = new ArrayList();
                    foreach (FileInfo NextFile in nextFolder.GetFiles())
                    {
                        if (NextFile.Extension == ".jpg" || NextFile.Extension == ".gif")
                        {
                            AppenSpaceCmd("上传图片");
                            UploadImageData imagedata = QQSpaceHelper.UploadPic(NextFile.FullName, spacecc, qqhao);
                            imgs.Add(imagedata);
                        }
                    }
                    string content = " ";
                    if (!IsGuidByReg(nextFolder.Name))
                    {
                        content = nextFolder.Name;
                    }
                    QQSpaceHelper.SendShuoshuoWithPic(content, imgs, spacecc, qqhao);
                    Directory.Move(nextFolder.FullName, "已发布/" + nextFolder.Name);
                    AppenSpaceCmd(nickname + "[" + qqhaoma + "]发布完成");
                }
                int jiange = Convert.ToInt32(this.nud_spacejiange.Value);
                AppenSpaceCmd("此次发布完毕,等待" + jiange.ToString() + "分钟");
                Thread.Sleep(jiange * 60 * 1000);
            }
        }
Exemplo n.º 4
0
        internal static void SendShuoshuoWithPic(string content, ArrayList imgs, CookieContainer spacecc, QQHao qqhao)
        {
            string richval = "";
            string pic_bo  = "";
            string poststr = "";
            string refer   = "http://user.qzone.qq.com/" + qqhao.Qqhaoma;
            string url     = "http://h5.qzone.qq.com/proxy/domain/taotao.qzone.qq.com/cgi-bin/emotion_cgi_publish_v6?g_tk=" + qqhao.G_tk + "&qzonetoken=" + qqhao.Token;

            foreach (UploadImageData imgdata in imgs)
            {
                string imgrichval = string.Format(",{0},{1},{2},{3},{4},{5},,{6},{7}", imgdata.data.albumid, imgdata.data.lloc, imgdata.data.sloc, imgdata.data.type, imgdata.data.height, imgdata.data.width, imgdata.data.height, imgdata.data.width);
                richval += imgrichval + "%09";
                string imgpicbo = "";
                HttpHelper1.GetStringInTwoKeyword(imgdata.data.pre, ref imgpicbo, "bo=", "!", 0);
                pic_bo += imgpicbo + "!,";
            }
            richval = richval.Substring(0, richval.Length - 3); //去除最后一个%09
            pic_bo  = pic_bo.Substring(0, pic_bo.Length - 1);   //去除最后一个逗号,
            pic_bo  = pic_bo + "%09" + pic_bo;
            string encodecontent = HttpUtility.UrlEncode(content);
            string encoderichval = richval.Replace("!", "%21").Replace(",", "%2c");
            string encodepicbo   = pic_bo.Replace("!", "%21").Replace(",", "%2c");

            poststr = "qzreferrer=http%3A%2F%2Fuser.qzone.qq.com%2F3213257524&syn_tweet_verson=1&paramstr=1&pic_template=&richtype=1&richval=" + encoderichval + "&special_url=&subrichtype=1&pic_bo=" + encodepicbo + "&who=1&con=" + encodecontent + "&feedversion=1&ver=1&ugc_right=1&to_sign=0&hostuin=" + qqhao.Qqhaoma + "&code_version=1&format=fs";
            string resulthtml = HttpHelper1.SendDataByPost(url, poststr, refer, ref spacecc);
        }
Exemplo n.º 5
0
        public static UploadImageData UploadPic(string filepath, CookieContainer spacecc, QQHao qqhao)
        {
            string           picpath = filepath;
            CookieCollection ccl     = spacecc.GetCookies(new Uri("http://qzone.qq.com"));
            string           url     = string.Format("http://shup.photo.qzone.qq.com/cgi-bin/upload/cgi_upload_image?g_tk={0}", qqhao.G_tk);
            FileStream       file    = new FileStream(picpath, FileMode.Open);

            byte[] bb = new byte[file.Length];
            file.Read(bb, 0, (int)file.Length);
            file.Close();
            Image  img    = byteArrayToImage(bb);
            string skey   = ccl[6].Value;
            string p_skey = ccl[1].Value;

            MsMultiPartFormData form = new MsMultiPartFormData();

            form.AddFormField("Filename", Path.GetFileName(filepath));
            form.AddFormField("qzonetoken", qqhao.Token);
            form.AddFormField("photoData", "filename");
            form.AddFormField("exif_info", "extendXml:");
            form.AddFormField("backUrls", "http://upbak.photo.qzone.qq.com/cgi-bin/upload/cgi_upload_image,http://119.147.64.75/cgi-bin/upload/cgi_upload_image");
            form.AddFormField("skey", skey);
            form.AddFormField("refer", "shuoshuo");
            form.AddFormField("output_charset", "utf-8");
            form.AddFormField("zzpaneluin", qqhao.Qqhaoma);
            form.AddFormField("uploadtype", "1");
            form.AddFormField("exttype", "0");
            form.AddFormField("hd_width", "2048");
            form.AddFormField("albumtype", "7");
            form.AddFormField("hd_height", "10000");
            form.AddFormField("zzpanelkey", "");
            form.AddFormField("charset", "utf-8");
            form.AddFormField("filename", "filename");
            form.AddFormField("p_uin", qqhao.Qqhaoma);
            form.AddFormField("hd_quality", "96");
            form.AddFormField("output_type", "json");
            form.AddFormField("uin", qqhao.Qqhaoma);
            form.AddFormField("p_skey", p_skey);
            form.AddFormField("upload_hd", "1");
            form.AddFormField("Filename", "xml");
            form.AddFormField("output_type", "xml");
            form.AddStreamFile("filename", Path.GetFileName(picpath), bb);
            form.AddFormField("Upload", "Submit Query");
            form.PrepareFormData();

            form.GetFormData();
            string host = "shup.photo.qzone.qq.com";
            //url = string.Format("http://upload.t.qq.com/asyn/uploadpicCommon.php?call=2&uin={0}&g_tk={1}&rand={2}&_ps1={3}&_ps2=null", uin, weiboGtk, rand.NextDouble(), _ps1);
            string ContentType = "multipart/form-data; boundary=" + form.Boundary;

            HttpHelper help = new HttpHelper();
            HttpItem   item = new HttpItem()
            {
                URL = url,
                CookieCollection = ccl,
                ResultCookieType = ResultCookieType.CookieCollection,
                Host             = host,
                Accept           = "*/*",
                UserAgent        = "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.101 Safari/537.36",
                ContentType      = ContentType,
                Method           = "POST",
                PostDataType     = PostDataType.Byte,
                PostdataByte     = form.GetFormData().ToArray(),
                Encoding         = Encoding.UTF8,
                ProxyIp          = "ieproxy"
            };

            item.Header.Add("Origin", "http://qzs.qq.com");

            HttpResult      result     = help.GetHtml(item);
            string          resulthtml = result.Html;//上传图片,测试成功
            string          jsonstr    = resulthtml.Replace("_Callback(", "").Replace(");", "");
            UploadImageData imagedata2 = Newtonsoft.Json.JsonConvert.DeserializeObject <UploadImageData>(jsonstr);

            return(imagedata2);
        }