Ejemplo n.º 1
0
        /// <summary>
        /// Get the QQ discussion group list
        /// </summary>
        /// <param name="isDiscussionGroupAccountDetailedInfo"></param>
        /// <returns></returns>
        public List <DiscussionAccount> GetDiscussionGroupList(bool isDiscussionGroupAccountDetailedInfo = true)
        {
            string      url      = "http://s.web2.qq.com/api/get_discus_list?clientid=53999199&psessionid=#{psessionid}&vfwebqq=#{vfwebqq}&t=#{t}".Replace("#{psessionid}", smartQQ.PSessionId).Replace("#{vfwebqq}", smartQQ.VFWebQQ).Replace("#{t}", HTTP.AID_TimeStamp());
            string      dat      = HTTP.Get(url, "http://d1.web2.qq.com/proxy.html?v=20151105001&callback=1&id=2");
            Discussions disscuss = (Discussions)JsonConvert.DeserializeObject(dat, typeof(Discussions));

            smartQQ.DiscussionAccounts = new List <DiscussionAccount>();
            if (disscuss.result != null)
            {
                foreach (var discussion in disscuss.result.dnamelist)
                {
                    DiscussionAccount discussionAccount = new DiscussionAccount();
                    discussionAccount.Did  = discussion.did;
                    discussionAccount.Name = discussion.name;
                    smartQQ.DiscussionAccounts.Add(discussionAccount);
                }
            }

            if (isDiscussionGroupAccountDetailedInfo)
            {
                foreach (var discussion in smartQQ.DiscussionAccounts)
                {
                    LoadDiscussionAccountDetailedInfo(discussion);
                }
            }

            return(smartQQ.DiscussionAccounts);
        }
Ejemplo n.º 2
0
        public void GetOnlineAccounts()
        {
            string url = "http://d1.web2.qq.com/channel/get_online_buddies2?vfwebqq=#{vfwebqq}&clientid=53999199&psessionid=#{psessionid}&t=#{t}".Replace("#{vfwebqq}", smartQQ.VFWebQQ).Replace("#{psessionid}", smartQQ.PSessionId).Replace("#{t}", HTTP.AID_TimeStamp());

            HTTP.Get(url, "http://d1.web2.qq.com/proxy.html?v=20151105001&callback=1&id=2");

            url = "http://d1.web2.qq.com/channel/get_recent_list2";
            string        url1          = "{\"vfwebqq\":\"#{vfwebqq}\",\"clientid\":53999199,\"psessionid\":\"#{psessionid}\"}".Replace("#{vfwebqq}", smartQQ.VFWebQQ).Replace("#{psessionid}", smartQQ.PSessionId);
            string        dat           = HTTP.Post(url, "r=" + HttpUtility.UrlEncode(url1), "http://d1.web2.qq.com/proxy.html?v=20151105001&callback=1&id=2");
            OnlineFirends onlineFirends = (OnlineFirends)JsonConvert.DeserializeObject(dat, typeof(OnlineFirends));

            if (onlineFirends.result == null)
            {
                return;
            }

            Dictionary <string, int> OnlineUserStatusMap = new Dictionary <string, int>();

            foreach (var onlineFirend in onlineFirends.result)
            {
                OnlineUserStatusMap.Add(onlineFirend.uin, onlineFirend.type);
            }

            foreach (var firend in smartQQ.FriendAccounts)
            {
                if (OnlineUserStatusMap.ContainsKey(firend.Uin))
                {
                    firend.OnlineType = OnlineUserStatusMap[firend.Uin];
                }
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Get the QQ profile
        /// </summary>
        /// <returns></returns>
        public SmartQQWrapper GetQQProfile()
        {
            string     url  = "http://s.web2.qq.com/api/get_self_info2?t=#{t}".Replace("#{t}", HTTP.AID_TimeStamp());
            string     dat  = HTTP.Get(url, "http://s.web2.qq.com/proxy.html?v=20130916001&callback=1&id=1");
            FriendInfo info = (FriendInfo)JsonConvert.DeserializeObject(dat, typeof(FriendInfo));

            if (info.result != null)
            {
                smartQQ.Occupation = info.result.occupation;
                smartQQ.Phone      = info.result.phone;
                smartQQ.College    = info.result.college;
                smartQQ.Blood      = info.result.blood;
                smartQQ.Homepage   = info.result.homepage;
                smartQQ.Country    = info.result.country;
                smartQQ.City       = info.result.city;
                smartQQ.Personal   = info.result.personal;
                smartQQ.Nick       = info.result.nick;
                smartQQ.Email      = info.result.email;
                smartQQ.Province   = info.result.province;
                smartQQ.Gender     = info.result.gender;
                smartQQ.Face       = info.result.face;
            }

            return(smartQQ);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Load the detailed account profile
        /// </summary>
        /// <param name="account"></param>
        private void LoadAccountDetailedInfo(QQFriendAccount account)
        {
            string getFriendInfoUrl = "http://s.web2.qq.com/api/get_friend_info2?tuin=#{uin}&vfwebqq=#{vfwebqq}&clientid=53999199&psessionid=#{psessionid}&t=#{t}".Replace("#{t}", HTTP.AID_TimeStamp());

            getFriendInfoUrl = getFriendInfoUrl.Replace("#{uin}", account.Uin).Replace("#{vfwebqq}", smartQQ.VFWebQQ).Replace("#{psessionid}", smartQQ.PSessionId);
            string     retFriendInfo = HTTP.Get(getFriendInfoUrl, "http://s.web2.qq.com/proxy.html?v=20130916001&callback=1&id=1");
            FriendInfo friendInfo    = (FriendInfo)JsonConvert.DeserializeObject(retFriendInfo, typeof(FriendInfo));

            if (friendInfo.result != null)
            {
                account.Blood      = friendInfo.result.blood;
                account.Occupation = friendInfo.result.occupation;
                account.College    = friendInfo.result.college;
                account.Homepage   = friendInfo.result.homepage;
                account.Country    = friendInfo.result.country;
                account.City       = friendInfo.result.city;
                account.Nick       = friendInfo.result.nick;
                account.Email      = friendInfo.result.email;
                account.Phone      = friendInfo.result.phone;
                account.Mobile     = friendInfo.result.mobile;
                account.Province   = friendInfo.result.province;
                account.Gender     = friendInfo.result.gender;

                if (friendInfo.result.birthday.year != 0 && friendInfo.result.birthday.month != 0 && friendInfo.result.birthday.day != 0)
                {
                    account.Birthday = new DateTime(friendInfo.result.birthday.year, friendInfo.result.birthday.month, friendInfo.result.birthday.day);
                }
            }

            account.Account = GetQQAccountByUin(account.Uin);
        }
Ejemplo n.º 5
0
        public string GetQQAccountByUin(string uin)
        {
            string friendAAAccount = "";

            string getFriendAccountUrl = "http://s.web2.qq.com/api/get_friend_uin2?tuin=#{uin}&type=1&vfwebqq=#{vfwebqq}&t=#{t}";

            getFriendAccountUrl = getFriendAccountUrl.Replace("#{uin}", uin).Replace("#{vfwebqq}", smartQQ.VFWebQQ);
            string        retFriendAccoun = HTTP.Get(getFriendAccountUrl, "http://s.web2.qq.com/proxy.html?v=20130916001&callback=1&id=1");
            FirendAccount firendAccount   = (FirendAccount)JsonConvert.DeserializeObject(retFriendAccoun, typeof(FirendAccount));

            if (firendAccount.result != null)
            {
                friendAAAccount = firendAccount.result.account;
            }

            return(friendAAAccount);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Get the QQ discussion group member profile
        /// </summary>
        /// <param name="discussionAccount"></param>
        private void LoadDiscussionAccountDetailedInfo(DiscussionAccount discussionAccount)
        {
            string url = "http://d1.web2.qq.com/channel/get_discu_info?did=#{discuss_id}&psessionid=#{psessionid}&vfwebqq=#{vfwebqq}&clientid=53999199&t=#{t}".Replace("#{t}", HTTP.AID_TimeStamp());

            url = url.Replace("#{discuss_id}", discussionAccount.Did).Replace("#{psessionid}", smartQQ.PSessionId).Replace("#{vfwebqq}", smartQQ.VFWebQQ);
            string         dat            = HTTP.Get(url, "http://d1.web2.qq.com/proxy.html?v=20151105001&callback=1&id=2");
            DiscussionInfo discussionInfo = (DiscussionInfo)JsonConvert.DeserializeObject(dat, typeof(DiscussionInfo));

            Dictionary <string, string> MemberList = new Dictionary <string, string>();

            if (discussionInfo.result.mem_info != null)
            {
                foreach (var memberInfo in discussionInfo.result.mem_info)
                {
                    MemberList.Add(memberInfo.uin, memberInfo.nick);
                }
            }

            Dictionary <string, string> MemberStatusList = new Dictionary <string, string>();

            if (discussionInfo.result.mem_status != null)
            {
                foreach (var status in discussionInfo.result.mem_status)
                {
                    MemberStatusList.Add(status.uin, status.status);
                }
            }

            if (discussionInfo.result.info.mem_list != null)
            {
                discussionAccount.Members = new List <DiscussionMember>();
                foreach (var member in discussionInfo.result.info.mem_list)
                {
                    DiscussionMember discussionMember = new DiscussionMember();
                    discussionMember.Ruin   = member.ruin;
                    discussionMember.Uin    = member.mem_uin;
                    discussionMember.Name   = MemberList.ContainsKey(discussionMember.Uin) ? MemberList[discussionMember.Uin] : "";
                    discussionMember.Status = MemberStatusList.ContainsKey(discussionMember.Uin) ? MemberStatusList[discussionMember.Uin] : "";

                    discussionAccount.Members.Add(discussionMember);
                }
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Check the QR Code status
        /// </summary>
        /// <returns></returns>
        public QRStatus CheckQRCodeStatus()
        {
            QRStatus status = new QRStatus();
            string   dat    = HTTP.Get("https://ssl.ptlogin2.qq.com/ptqrlogin?webqq_type=10&remember_uin=1&login2qq=1&aid=501004106&u1=http%3A%2F%2Fw.qq.com%2Fproxy.html%3Flogin2qq%3D1%26webqq_type%3D10 &ptredirect=0&ptlang=2052&daid=164&from_ui=1&pttype=1&dumy=&fp=loginerroralert &action=0-0-157510&mibao_css=m_webqq&t=1&g=1&js_type=0&js_ver=10143&login_sig=&pt_randsalt=0",
                                       "https://ui.ptlogin2.qq.com/cgi-bin/login?daid=164&target=self&style=16&mibao_css=m_webqq&appid=501004106&enable_qlogin=0&no_verifyimg=1 &s_url=http%3A%2F%2Fw.qq.com%2Fproxy.html&f_url=loginerroralert &strong_login=1&login_state=10&t=20131024001");

            System.Console.Out.WriteLine("The response data for checking login QR code status :" + dat);

            if (dat == null || dat.Trim().Length == 0)
            {
                return(null);
            }

            dat = dat.Substring(dat.IndexOf("(") + 1);
            dat = dat.Substring(0, dat.IndexOf(");"));
            string[] temp = dat.Split(',');

            status.StatusCode  = temp[0].Replace("'", "");
            status.StatusText  = temp[4].Replace("'", "");;
            status.RedirectUrl = temp[2].Replace("'", "");;

            return(status);
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Process login request
        /// </summary>
        /// <param name="redirectUrl"></param>
        /// <returns></returns>
        public SmartQQWrapper ProcessLoginRequest(string redirectUrl)
        {
            string url = "";
            string dat = "";

            // 1.
            string ptwebqq = "";

            for (int i = 0; i < 3; i++)
            {
                try
                {
                    dat = HTTP.Get(redirectUrl, "http://s.web2.qq.com/proxy.html?v=20130916001&callback=1&id=1");
                    Uri uri = new Uri("http://web2.qq.com/");
                    ptwebqq = HTTP.cookies.GetCookies(uri)["ptwebqq"].Value;
                    break;
                }
                catch (Exception ex)
                {
                }
            }

            // 2.
            string vfwebqq = "";

            for (int i = 0; i < 3; i++)
            {
                try
                {
                    url     = String.Format("http://s.web2.qq.com/api/getvfwebqq?ptwebqq={0}&clientid=53999199&psessionid=&t={1}", ptwebqq, HTTP.AID_TimeStamp());
                    dat     = HTTP.Get(url, "http://s.web2.qq.com/proxy.html?v=20130916001&callback=1&id=1");
                    vfwebqq = dat.Substring(dat.IndexOf("\"vfwebqq\":") + "\"vfwebqq\":".Length + 1);
                    vfwebqq = vfwebqq.Substring(0, vfwebqq.IndexOf("\""));
                    break;
                }
                catch (Exception ex)
                {
                }
            }

            // 3.
            string psessionid = "";
            string qqNbr      = "";

            for (int i = 0; i < 3; i++)
            {
                try
                {
                    url = "http://d1.web2.qq.com/channel/login2";
                    string url1 = "{\"ptwebqq\":\"#{ptwebqq}\",\"clientid\":53999199,\"psessionid\":\"\",\"status\":\"online\"}".Replace("#{ptwebqq}", ptwebqq);
                    url1       = "r=" + HttpUtility.UrlEncode(url1);
                    dat        = HTTP.Post(url, url1, "http://d1.web2.qq.com/proxy.html?v=20151105001&callback=1&id=2");
                    psessionid = dat.Substring(dat.IndexOf("\"psessionid\":") + "\"psessionid\":".Length + 1);
                    psessionid = psessionid.Substring(0, psessionid.IndexOf("\""));

                    qqNbr = dat.Substring(dat.IndexOf("\"uin\":") + "\"uin\":".Length);
                    qqNbr = qqNbr.Substring(0, qqNbr.IndexOf(","));
                    break;
                }
                catch (Exception ex)
                {
                }
            }

            string hash = "";

            hash = HTTP.AID_Hash(qqNbr, ptwebqq);

            SmartQQWrapper smartQQ = new SmartQQWrapper();

            smartQQ.PTWebQQ    = ptwebqq;
            smartQQ.VFWebQQ    = vfwebqq;
            smartQQ.PSessionId = psessionid;
            smartQQ.QQAccount  = qqNbr;
            smartQQ.Hash       = hash;

            return(smartQQ);
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Get the QQ group member profile
        /// </summary>
        /// <param name="groupAccount"></param>
        private void LoadGroupAccountDetailedInfo(GroupAccount groupAccount)
        {
            string    gcode     = groupAccount.Code;
            string    url       = "http://s.web2.qq.com/api/get_group_info_ext2?gcode=#{group_code}&vfwebqq=#{vfwebqq}&t=#{t}".Replace("#{group_code}", gcode).Replace("#{vfwebqq}", smartQQ.VFWebQQ).Replace("#{t}", HTTP.AID_TimeStamp());
            string    dat       = HTTP.Get(url, "http://s.web2.qq.com/proxy.html?v=20130916001&callback=1&id=1");
            GroupInfo groupInfo = (GroupInfo)JsonConvert.DeserializeObject(dat, typeof(GroupInfo));

            if (groupInfo.result == null)
            {
                return;
            }

            groupAccount.Class      = ""; //groupInfo.result.ginfo.class;
            groupAccount.Code       = groupInfo.result.ginfo.code;
            groupAccount.CreateTime = groupInfo.result.ginfo.createtime;
            groupAccount.Memo       = groupInfo.result.ginfo.memo;
            groupAccount.Level      = groupInfo.result.ginfo.level;
            groupAccount.Name       = groupInfo.result.ginfo.name;
            groupAccount.Owner      = groupInfo.result.ginfo.owner;

            Dictionary <string, string> GroupCardList = new Dictionary <string, string>();

            if (groupInfo.result.cards != null)
            {
                foreach (var goupCard in groupInfo.result.cards)
                {
                    GroupCardList.Add(goupCard.muin, goupCard.card);
                }
            }

            Dictionary <string, GroupMember> GroupMemberList = new Dictionary <string, GroupMember>();

            if (groupInfo.result.minfo != null)
            {
                foreach (var minfo in groupInfo.result.minfo)
                {
                    GroupMember groupMember = new GroupMember();
                    groupMember.Nick     = minfo.nick;
                    groupMember.Province = minfo.province;
                    groupMember.Gender   = minfo.gender;
                    groupMember.Uin      = minfo.uin;
                    groupMember.Country  = minfo.country;
                    groupMember.City     = minfo.city;
                    groupMember.Card     = GroupCardList.ContainsKey(minfo.uin) ? GroupCardList[minfo.uin] : "";

                    GroupMemberList.Add(minfo.uin, groupMember);
                }
            }

            groupAccount.Members = new List <GroupMember>();
            foreach (var member in groupInfo.result.ginfo.members)
            {
                if (GroupMemberList.ContainsKey(member.muin))
                {
                    groupAccount.Members.Add(GroupMemberList[member.muin]);
                }
            }

            foreach (var member in groupAccount.Members)
            {
                member.Account = GetQQAccountByUin(member.Uin);
            }
        }