Ejemplo n.º 1
0
        public static BatchGetContact GetContactList()
        {
            var reqCookies = new CookieContainer();

            CookieContainer resCookies = null;

            reqCookies = new CookieContainer();
            reqCookies.Add(new Cookie("MM_WX_NOTIFY_STATE", "1", "/", "wx.qq.com"));
            reqCookies.Add(new Cookie("MM_WX_SOUND_STATE", "1", "/", "wx.qq.com"));
            reqCookies.Add(new Cookie("last_wxuin", LoginHelper.LoginPageCookie.wxuin, "/", "wx.qq.com"));
            reqCookies.Add(new Cookie("login_frequency", "1", "/", "wx.qq.com"));
            reqCookies.Add(new Cookie("mm_lang", "zh_CN", "/", "wx.qq.com"));
            reqCookies.Add(new Cookie("pgv_pvi", LoginHelper.pgv_pvi, "/", "wx.qq.com"));
            reqCookies.Add(new Cookie("pgv_si", LoginHelper.pgv_si, "/", "wx.qq.com"));
            reqCookies.Add(new Cookie("webwx_auth_ticket", LoginHelper.LoginPageCookie.webwx_auth_ticket, "/", "wx.qq.com"));
            reqCookies.Add(new Cookie("webwx_data_ticket", LoginHelper.LoginPageCookie.webwx_data_ticket, "/", "wx.qq.com"));
            reqCookies.Add(new Cookie("webwxuvid", LoginHelper.LoginPageCookie.webwxuvid, "/", "wx.qq.com"));
            reqCookies.Add(new Cookie("wxloadtime", CalcTimeUtil.GetUnixDateTime(new TimeSpan(365, 0, 0, 0)), "/", "wx.qq.com"));
            reqCookies.Add(new Cookie("wxsid", LoginHelper.LoginPageCookie.wxsid, "/", "wx.qq.com"));
            reqCookies.Add(new Cookie("wxuin", LoginHelper.LoginPageCookie.wxuin, "/", "wx.qq.com"));

            var webwxgetcontactUrl = string.Format(webwxgetcontactUrlTemple, RandomUtil.GetRandom(10), LoginHelper.LoginPageXml.skey);

            string json = WebClientUtil.GetResponseOnCookie(webwxgetcontactUrl, "get", reqCookies, out resCookies);

            InitHelper.BatchGetContact = SerializeUtil.Deserialize <BatchGetContact>(json);

            return(InitHelper.BatchGetContact);
        }
Ejemplo n.º 2
0
        private static string CheckeSync()
        {
            if (LoginHelper.LoginPageCookie == null || LoginHelper.LoginPageCookie == null)
            {
                return(string.Empty);
            }

            var reqCookies = new CookieContainer();

            reqCookies.Add(new Cookie("pgv_pvi", LoginHelper.pgv_pvi, "/", "wx.qq.com"));
            reqCookies.Add(new Cookie("pgv_si", LoginHelper.pgv_si, "/", "wx.qq.com"));
            reqCookies.Add(new Cookie("refreshTimes", "2", "/", "wx.qq.com"));
            reqCookies.Add(new Cookie("MM_WX_NOTIFY_STATE", "1", "/", "wx.qq.com"));
            reqCookies.Add(new Cookie("MM_WX_SOUND_STATE", "1", "/", "wx.qq.com"));
            reqCookies.Add(new Cookie("mm_lang", "zh_CN", "/", "wx.qq.com"));
            reqCookies.Add(new Cookie("webwxuvid", LoginHelper.LoginPageCookie.webwxuvid, "/", "wx.qq.com"));
            reqCookies.Add(new Cookie("webwx_auth_ticket", LoginHelper.LoginPageCookie.webwx_auth_ticket, "/", "wx.qq.com"));
            reqCookies.Add(new Cookie("webwx_data_ticket", LoginHelper.LoginPageCookie.webwx_data_ticket, "/", "wx.qq.com"));
            reqCookies.Add(new Cookie("login_frequency", "1", "/", "wx.qq.com"));
            reqCookies.Add(new Cookie("last_wxuin", "LoginHelper.LoginPageCookie.wxuin", "/", "wx.qq.com"));
            reqCookies.Add(new Cookie("wxloadtime", "1495855277_expired", "/", "wx.qq.com"));
            reqCookies.Add(new Cookie("wxuin", LoginHelper.LoginPageCookie.wxuin, "/", "wx.qq.com"));
            reqCookies.Add(new Cookie("wxsid", LoginHelper.LoginPageCookie.wxsid, "/", "wx.qq.com"));

            CookieContainer resCookies = null;

            var synckey = string.Empty;

            if (InitHelper.WebWeixinInit != null && (preSyncKey == null || preSyncKey.Count == 0) && InitHelper.WebWeixinInit.SyncKey != null && InitHelper.WebWeixinInit.SyncKey.Count > 0)
            {
                foreach (var item in InitHelper.WebWeixinInit.SyncKey.List)
                {
                    synckey += item.Key + "_" + item.Val + "|";
                }
                synckey = synckey.Substring(0, synckey.Length - 1);
            }
            else if (preSyncKey != null && preSyncKey.Count > 0 && preSyncKey.Count > 0)
            {
                foreach (var item in preSyncKey.List)
                {
                    synckey += item.Key + "_" + item.Val + "|";
                }
                synckey = synckey.Substring(0, synckey.Length - 1);
            }

            var checkeUrl = string.Format(CheckeUrlTemple, CalcTimeUtil.GetUnixDateTime() + "000", LoginHelper.LoginPageXml.skey, LoginHelper.LoginPageCookie.wxsid, LoginHelper.LoginPageCookie.wxuin, synckey);

            if (LoginHelper.WX2)
            {
                checkeUrl = checkeUrl.Replace("//webpush.", "//webpush2.");
            }

            return(WebClientUtil.GetResponseOnCookie(checkeUrl, "get", reqCookies, out resCookies));
        }
Ejemplo n.º 3
0
        public static bool InitWidthLogin()
        {
            try
            {
                var reqCookies = new CookieContainer();

                CookieContainer resCookies = null;

                reqCookies = new CookieContainer();
                reqCookies.Add(new Cookie("MM_WX_NOTIFY_STATE", "1", "/", "wx.qq.com"));
                reqCookies.Add(new Cookie("MM_WX_SOUND_STATE", "1", "/", "wx.qq.com"));
                reqCookies.Add(new Cookie("last_wxuin", LoginHelper.LoginPageCookie.wxuin, "/", "wx.qq.com"));
                reqCookies.Add(new Cookie("login_frequency", "1", "/", "wx.qq.com"));
                reqCookies.Add(new Cookie("mm_lang", "zh_CN", "/", "wx.qq.com"));
                reqCookies.Add(new Cookie("pgv_pvi", LoginHelper.pgv_pvi, "/", "wx.qq.com"));
                reqCookies.Add(new Cookie("pgv_si", LoginHelper.pgv_si, "/", "wx.qq.com"));
                reqCookies.Add(new Cookie("webwx_auth_ticket", LoginHelper.LoginPageCookie.webwx_auth_ticket, "/", "wx.qq.com"));
                reqCookies.Add(new Cookie("webwx_data_ticket", LoginHelper.LoginPageCookie.webwx_data_ticket, "/", "wx.qq.com"));
                reqCookies.Add(new Cookie("webwxuvid", LoginHelper.LoginPageCookie.webwxuvid, "/", "wx.qq.com"));
                reqCookies.Add(new Cookie("wxloadtime", CalcTimeUtil.GetUnixDateTime(new TimeSpan(365, 0, 0, 0)), "/", "wx.qq.com"));
                reqCookies.Add(new Cookie("wxsid", LoginHelper.LoginPageCookie.wxsid, "/", "wx.qq.com"));
                reqCookies.Add(new Cookie("wxuin", LoginHelper.LoginPageCookie.wxuin, "/", "wx.qq.com"));

                var weixinInitUrl = string.Format(weixinInitUrlTemple, LoginHelper.LoginPageXml.pass_ticket, new object().GetHashCode());

                var data = new Dictionary <string, string>();

                var postData = "{\"BaseRequest\":{\"Uin\":\"" + LoginHelper.LoginPageCookie.wxuin + "\",\"Sid\":\"" + LoginHelper.LoginPageCookie.wxsid + "\",\"Skey\":\"" + LoginHelper.LoginPageXml.skey + "\",\"DeviceID\":\"e478901587692997\"}}";

                data.Add(WebClientUtil.JsonDataPrex, postData);

                string json = WebClientUtil.GetResponseOnCookie(weixinInitUrl, "post", reqCookies, out resCookies, data, "application/json;charset=UTF-8");

                InitHelper.WebWeixinInit = SerializeUtil.Deserialize <WebWeixinInit>(json);

                if (InitHelper.WebWeixinInit == null || WebWeixinInit.BaseResponse.Ret != 0)
                {
                    return(false);
                }
                return(true);
            }
            catch
            {
            }
            return(false);
        }
Ejemplo n.º 4
0
        public static Image GetImage(string headerImageUrl)
        {
            var reqCookies = new CookieContainer();

            reqCookies = new CookieContainer();
            reqCookies.Add(new Cookie("MM_WX_NOTIFY_STATE", "1", "/", "wx.qq.com"));
            reqCookies.Add(new Cookie("MM_WX_SOUND_STATE", "1", "/", "wx.qq.com"));
            reqCookies.Add(new Cookie("last_wxuin", LoginHelper.LoginPageCookie.wxuin, "/", "wx.qq.com"));
            reqCookies.Add(new Cookie("login_frequency", "1", "/", "wx.qq.com"));
            reqCookies.Add(new Cookie("mm_lang", "zh_CN", "/", "wx.qq.com"));
            reqCookies.Add(new Cookie("pgv_pvi", LoginHelper.pgv_pvi, "/", "wx.qq.com"));
            reqCookies.Add(new Cookie("pgv_si", LoginHelper.pgv_si, "/", "wx.qq.com"));
            reqCookies.Add(new Cookie("webwx_auth_ticket", LoginHelper.LoginPageCookie.webwx_auth_ticket, "/", "wx.qq.com"));
            reqCookies.Add(new Cookie("webwx_data_ticket", LoginHelper.LoginPageCookie.webwx_data_ticket, "/", "wx.qq.com"));
            reqCookies.Add(new Cookie("webwxuvid", LoginHelper.LoginPageCookie.webwxuvid, "/", "wx.qq.com"));
            reqCookies.Add(new Cookie("wxloadtime", CalcTimeUtil.GetUnixDateTime(new TimeSpan(365, 0, 0, 0)), "/", "wx.qq.com"));
            reqCookies.Add(new Cookie("wxsid", LoginHelper.LoginPageCookie.wxsid, "/", "wx.qq.com"));
            reqCookies.Add(new Cookie("wxuin", LoginHelper.LoginPageCookie.wxuin, "/", "wx.qq.com"));
            return(Image.FromStream(WebClientUtil.GetImageOnCookie("https://wx.qq.com" + headerImageUrl, "get", reqCookies)));
        }
Ejemplo n.º 5
0
        private static WXSync SyncMessage()
        {
            if (InitHelper.WebWeixinInit != null)
            {
                var synckey = string.Empty;

                int count = 0;

                if (preSyncKey == null || preSyncKey.Count == 0)
                {
                    foreach (var item in InitHelper.WebWeixinInit.SyncKey.List)
                    {
                        synckey += "{\"Key\":" + item.Key + ",\"Val\":" + item.Val + "},";
                    }
                    if (!string.IsNullOrEmpty(synckey))
                    {
                        synckey = synckey.Substring(0, synckey.Length - 1);
                    }
                    count = InitHelper.WebWeixinInit.SyncKey.Count;
                }
                else if (preSyncKey.List != null && preSyncKey.List.Count > 0)
                {
                    foreach (var item in preSyncKey.List)
                    {
                        synckey += "{\"Key\":" + item.Key + ",\"Val\":" + item.Val + "},";
                    }
                    if (!string.IsNullOrEmpty(synckey))
                    {
                        synckey = synckey.Substring(0, synckey.Length - 1);
                    }
                    count = preSyncKey.Count;
                }


                var json = "{\"BaseRequest\":{\"Uin\":" + LoginHelper.LoginPageCookie.wxuin + ",\"Sid\":\"" + LoginHelper.LoginPageCookie.wxsid + "\",\"Skey\":\"" + LoginHelper.LoginPageXml.skey + "\",\"DeviceID\":\"e370515259583130\"},\"SyncKey\":{\"Count\":" + count + ",\"List\":[" + synckey + "]},\"rr\":-" + CalcTimeUtil.GetUnixDateTime() + "}";


                var reqCookies = new CookieContainer();
                reqCookies.Add(new Cookie("pgv_pvi", LoginHelper.pgv_pvi, "/", "wx.qq.com"));
                reqCookies.Add(new Cookie("pgv_si", LoginHelper.pgv_si, "/", "wx.qq.com"));
                reqCookies.Add(new Cookie("refreshTimes", "2", "/", "wx.qq.com"));
                reqCookies.Add(new Cookie("MM_WX_NOTIFY_STATE", "1", "/", "wx.qq.com"));
                reqCookies.Add(new Cookie("MM_WX_SOUND_STATE", "1", "/", "wx.qq.com"));
                reqCookies.Add(new Cookie("mm_lang", "zh_CN", "/", "wx.qq.com"));
                reqCookies.Add(new Cookie("webwxuvid", LoginHelper.LoginPageCookie.webwxuvid, "/", "wx.qq.com"));
                reqCookies.Add(new Cookie("webwx_auth_ticket", LoginHelper.LoginPageCookie.webwx_auth_ticket, "/", "wx.qq.com"));
                reqCookies.Add(new Cookie("webwx_data_ticket", LoginHelper.LoginPageCookie.webwx_data_ticket, "/", "wx.qq.com"));
                reqCookies.Add(new Cookie("login_frequency", "1", "/", "wx.qq.com"));
                reqCookies.Add(new Cookie("last_wxuin", "LoginHelper.LoginPageCookie.wxuin", "/", "wx.qq.com"));
                reqCookies.Add(new Cookie("wxloadtime", "1495855277_expired", "/", "wx.qq.com"));
                reqCookies.Add(new Cookie("wxuin", LoginHelper.LoginPageCookie.wxuin, "/", "wx.qq.com"));
                reqCookies.Add(new Cookie("wxsid", LoginHelper.LoginPageCookie.wxsid, "/", "wx.qq.com"));

                CookieContainer resCookies = null;

                var SyncUrl = string.Format(SyncUrlTemple, LoginHelper.LoginPageCookie.wxsid, LoginHelper.LoginPageXml.skey, LoginHelper.LoginPageXml.pass_ticket);

                if (LoginHelper.WX2)
                {
                    SyncUrl = SyncUrl.Replace("//wx.", "//wx2.");
                }

                var dic = new Dictionary <string, string>();

                dic.Add(WebClientUtil.JsonDataPrex, json);

                return(SerializeUtil.Deserialize <WXSync>(WebClientUtil.GetResponseOnCookie(SyncUrl, "post", reqCookies, out resCookies, dic, "application/json;charset=UTF-8")));
            }
            return(null);
        }