示例#1
0
        /// 发送群消息
        public static bool SendMessageToGroup(string gin, string content)
        {
            if (content.Equals(""))
            {
                return(false);
            }
            if (gin.Equals(""))
            {
                return(false);
            }
            MsgId++;
            content = content.Replace("\r\n", "\n");
            content = content.Replace("\n\r", "\n");
            content = content.Replace("\r", "\n");
            content = content.Replace("\n", Environment.NewLine);
            try
            {
                string postData = "{\"group_uin\":" + gin
                                  + ",\"content\":\"[" + content.Replace(Environment.NewLine, "\\\\n")
                                  + ",[\\\"font\\\",{\\\"name\\\":\\\"宋体\\\",\\\"size\\\":11,\\\"style\\\":[0,0,0],\\\"color\\\":\\\"00FF00\\\"}]]\",\"face\":0,\"clientid\":" + ClientID
                                  + ",\"msg_id\":" + MsgId
                                  + ",\"psessionid\":\"" + psessionid
                                  + "\"}";
                postData = "r=" + HttpUtility.UrlEncode(postData);

                string referer = "http://d1.web2.qq.com/proxy.html?v=20151105001&callback=1&id=2";
                string url     = "http://d1.web2.qq.com/channel/send_qun_msg2";

                string dat = HTTP.HttpPost(url, referer, postData, Encoding.UTF8, false);

                dat = dat.Replace("{\"retcode\":", "");
                dat = dat.Replace("\"result\":\"", "");
                dat = dat.Replace("\"}", "");
                string[] tmp = dat.Split(',');
                if (tmp[0] == "0" && tmp[0] == "ok")
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch
            {
                return(false);
            }
        }
示例#2
0
 private void PollMessage()
 {
     try
     {
         string url      = "http://d1.web2.qq.com/channel/poll2";
         string packData = "{\"ptwebqq\":\"#{ptwebqq}\",\"clientid\":53999199,\"psessionid\":\"#{psessionid}\",\"key\":\"\"}";
         packData = packData.Replace("#{ptwebqq}", smartQQ.PTWebQQ).Replace("#{psessionid}", smartQQ.PSessionId);
         packData = "r=" + HttpUtility.UrlEncode(packData);
         HTTP.Post_Async_Action action = ReceiveMessage;
         HTTP.Post_Async(url, packData, action);
     }
     catch (Exception)
     {
         PollMessage();
     }
 }
示例#3
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);
        }
示例#4
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);
                }
            }
        }
示例#5
0
        public static void SecondLogin()
        {
            //二次登录
            string url = "http://d1.web2.qq.com/channel/login2";

            string url1 = "{\"ptwebqq\":\"" + ptwebqq + "\",\"clientid\":" + ClientID + ",\"psessionid\":\"\",\"status\":\"online\"}";

            url1 = "r=" + HttpUtility.UrlEncode(url1);
            string dat = HTTP.HttpPost(url, "http://d1.web2.qq.com/proxy.html?v=20151105001&callback=1&id=2", url1, Encoding.UTF8, true);

            Program.formlogin.textBoxLog.Text = dat;
            char[] t = new char[2];
            t[0] = ':';
            t[1] = ',';
            dat  = dat.Replace("{", "");
            dat  = dat.Replace("}", "");
            dat  = dat.Replace("\"", "");
            string[] tmp = dat.Split(t);

            psessionid = tmp[10];
            hash       = GetHash(Program.formlogin.QQNum, ptwebqq);
        }
示例#6
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);
        }
示例#7
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);
        }
示例#8
0
        /// <summary>
        /// Get QQ Friend List
        /// </summary>
        /// <param name="isLoadAccountDetailedInfo">The flag whether or not to load the friend profile</param>
        /// <returns></returns>
        public List <QQFriendAccount> GetFriendList(bool isLoadAccountDetailedInfo = false)
        {
            string url      = "http://s.web2.qq.com/api/get_user_friends2";
            string sendData = string.Format("r={{\"vfwebqq\":\"{0}\",\"hash\":\"{1}\"}}", smartQQ.VFWebQQ, smartQQ.Hash);
            string dat      = HTTP.Post(url, sendData, "http://s.web2.qq.com/proxy.html?v=20130916001&callback=1&id=1");

            Friends friend = (Friends)JsonConvert.DeserializeObject(dat, typeof(Friends));

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

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

            if (friend.result.markNames != null)
            {
                for (int i = 0; i < friend.result.markNames.Count; i++)
                {
                    MarkNameList.Add(friend.result.markNames[i].uin, friend.result.markNames[i].markname);
                }
            }

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

            if (friend.result.categories != null)
            {
                for (int i = 0; i < friend.result.categories.Count; i++)
                {
                    CategoryList.Add(friend.result.categories[i].index, friend.result.categories[i].name);
                }
            }

            Dictionary <string, QQFriendAccount> accounts = new Dictionary <string, QQFriendAccount>();
            string uin           = String.Empty;
            int    categoryIndex = -1;
            string categoryName  = String.Empty;

            if (friend.result.friends != null)
            {
                for (int i = 0; i < friend.result.friends.Count; i++)
                {
                    uin = friend.result.friends[i].uin;


                    QQFriendAccount account = null;
                    if (accounts.ContainsKey(uin))
                    {
                        account = accounts[uin];
                    }
                    else
                    {
                        account = new QQFriendAccount();
                        accounts.Add(uin, account);
                    }

                    account.Uin      = uin;
                    account.MarkName = MarkNameList.ContainsKey(uin) ? MarkNameList[uin] : "";

                    categoryIndex         = friend.result.friends[i].categories;
                    account.CategotyIndex = categoryIndex;
                    account.CategotyName  = CategoryList.ContainsKey(categoryIndex) ? CategoryList[categoryIndex] : "";

                    accounts[uin] = account;
                }
            }

            if (friend.result.info != null)
            {
                for (int i = 0; i < friend.result.info.Count; i++)
                {
                    uin = friend.result.info[i].uin;

                    QQFriendAccount account = null;
                    if (accounts.ContainsKey(uin))
                    {
                        account = accounts[uin];
                    }
                    else
                    {
                        account = new QQFriendAccount();
                        accounts.Add(uin, account);
                    }

                    account.Nick = friend.result.info[i].nick;

                    accounts[uin] = account;
                }
            }

            smartQQ.FriendAccounts = accounts.Values.ToList <QQFriendAccount>();
            if (isLoadAccountDetailedInfo)
            {
                foreach (QQFriendAccount account in smartQQ.FriendAccounts)
                {
                    LoadAccountDetailedInfo(account);
                }
            }

            return(smartQQ.FriendAccounts);
        }
示例#9
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];
                }
            }
        }
示例#10
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);
        }
示例#11
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);
        }
示例#12
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);
            }
        }
示例#13
0
        public static string GetTranslate(string str)
        {
            string lang    = "";
            int    strLen  = str.Length;
            int    bytLeng = System.Text.Encoding.UTF8.GetBytes(str).Length;

            if (strLen < bytLeng)
            {
                lang = "en";
            }
            if (lang.Equals(""))
            {
                lang = "zh-CN";
            }

            string messagetosend = "原文:" + str;

            string url = "https://translate.google.com/translate_a/single?client=t&sl=auto&tl=";

            url = url + lang + "&hl=zh-CN&dt=bd&dt=ex&dt=ld&dt=md&dt=qca&dt=rw&dt=rm&dt=ss&dt=t&dt=at&ie=UTF-8&oe=UTF-8&ssel=3&tsel=3&kc=0&tk=346111|219373&q=" + str;
            string temp = HTTP.HttpGet(url, 2000, Encoding.UTF8, "");

            string[] tmp = temp.Split('\"');
            if (tmp.Length != 0 && tmp[1] != null)
            {
                messagetosend = messagetosend + Environment.NewLine + "谷歌翻译:" + tmp[1];
            }
            else
            {
                messagetosend = messagetosend + Environment.NewLine + "谷歌翻译:异常";
            }

            url  = " http://fanyi.youdao.com/openapi.do?keyfrom=" + Program.formlogin.YoudaoKeyform + "&key=" + Program.formlogin.YoudaoKey + "&type=data&doctype=json&version=1.1&q=" + str;
            temp = HTTP.HttpGet(url);
            JsonYoudaoTranslateModel dat = (JsonYoudaoTranslateModel)JsonConvert.DeserializeObject(temp, typeof(JsonYoudaoTranslateModel));

            if (dat.errorcode == 0)
            {
                if (dat.translation[0] != null)
                {
                    messagetosend = messagetosend + Environment.NewLine + "有道翻译:" + dat.translation[0];
                }
                else
                {
                    messagetosend = messagetosend + Environment.NewLine + "有道翻译:异常";
                }
            }
            else if (dat.errorcode == 20)
            {
                messagetosend = messagetosend + Environment.NewLine + "有道翻译:不支持或文本过长";
            }
            else if (dat.errorcode == 50)
            {
                messagetosend = messagetosend + Environment.NewLine + "有道翻译:有道API密钥错误";
            }

            for (int i = 0; i < Program.formlogin.Badwords.Length; i++)
            {
                if (messagetosend.Contains(Program.formlogin.Badwords[i]))
                {
                    messagetosend = messagetosend.Replace(Program.formlogin.Badwords[i], "***");
                }
            }
            return(messagetosend);
        }
示例#14
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);
        }
示例#15
0
        public static string GetWiki(string keyword, string aim = "")
        {
            if (aim.Equals("互动百科") || aim.Equals("互动"))
            {
                string url  = "http://www.baike.com/wiki/" + keyword;
                string temp = HTTP.HttpGet(url);
                if (temp.Contains("尚未收录"))
                {
                    return("没有找到这个词条哦~");
                }
                temp = temp.Replace("<meta content=\"", "&");
                temp = temp.Replace("\" name=\"description\">", "&");
                string[] tmp = temp.Split('&');
                if (!tmp[1].Equals(""))
                {
                    return(tmp[1] + Environment.NewLine + "详情请查看http://www.baike.com/wiki/" + HttpUtility.UrlEncode(keyword));
                }
                else
                {
                    return("");
                }
            }
            else if (aim.Equals("维基百科") || aim.Equals("维基"))
            {
                string url  = "https://zh.wikipedia.org/w/api.php?action=query&prop=extracts&format=json&exsentences=2&exintro=&explaintext=&exsectionformat=plain&exvariant=zh&titles=" + keyword;
                string temp = HTTP.HttpGet(url);
                for (int i = 0; i < Program.formlogin.Badwords.Length; i++)
                {
                    if (temp.Contains(Program.formlogin.Badwords[i]) || keyword.Contains(Program.formlogin.Badwords[i]))
                    {
                        return("这个Wiki被河蟹吃掉了 QAQ");
                    }
                }
                JsonWikipediaModel     temp1 = (JsonWikipediaModel)JsonConvert.DeserializeObject(temp, typeof(JsonWikipediaModel));
                string[]               tmp   = temp1.query.pages.ToString().Split("{}".ToCharArray());
                JsonWikipediaPageModel pages = (JsonWikipediaPageModel)JsonConvert.DeserializeObject("{" + tmp[2] + "}", typeof(JsonWikipediaPageModel));

                if (pages.extract != null)
                {
                    return(pages.extract + Environment.NewLine + "详情请查看https://zh.wikipedia.org/wiki/" + HttpUtility.UrlEncode(keyword));
                }
                else
                {
                    return("没有找到这个Wiki哦~");
                }
            }
            else if (aim.Equals("百度百科") || aim.Equals("百度"))
            {
                string url  = "http://wapbaike.baidu.com/item/" + keyword;
                string temp = HTTP.HttpGet(url);

                if (temp.Contains("您所访问的页面不存在"))
                {
                    return("没有找到这个词条哦~");
                }
                if (temp.Contains("百科名片"))
                {
                    temp = temp.Replace("&quot;", "");
                    temp = temp.Replace("&", "");
                    temp = temp.Replace("百科名片", "&");
                    string[] tmp = temp.Split('&');

                    temp = tmp[1];
                    temp = temp.Replace("<p>", "&");
                    temp = temp.Replace("</p>", "&");
                    tmp  = temp.Split('&');

                    temp = tmp[1].Replace("</a>", "");
                    temp = temp.Replace("<b>", "");
                    temp = temp.Replace("</b>", "");
                    temp = temp.Replace("<i>", "");
                    temp = temp.Replace("</i>", "");

                    temp = temp.Replace("<a", "&");
                    temp = temp.Replace("\">", "&");
                    tmp  = temp.Split('&');

                    temp = "";
                    for (int i = 0; i < tmp.Length; i += 2)
                    {
                        if ((!tmp[i].Contains("card-info")) && (!tmp[i].Contains("div class")))
                        {
                            temp += tmp[i];
                        }
                    }
                    if (!temp.Equals(""))
                    {
                        return(temp + Environment.NewLine + "详情请查看http://wapbaike.baidu.com/item/" + HttpUtility.UrlEncode(keyword));
                    }
                    else
                    {
                        return("词条 " + keyword + " 请查看http://wapbaike.baidu.com/item/" + HttpUtility.UrlEncode(keyword));
                    }
                }
                else
                {
                    return("没有找到这个词条哦~");
                }
            }
            else
            {
                string temp1 = GetWiki(keyword, "百度");
                if (temp1.Contains("查看"))
                {
                    return(temp1 + " --百度百科");
                }

                temp1 = GetWiki(keyword, "互动");
                if (temp1.Contains("查看"))
                {
                    return(temp1 + " --互动百科");
                }

                temp1 = GetWiki(keyword, "维基");
                if (temp1.Contains("查看"))
                {
                    return(temp1 + " --维基百科");
                }

                else
                {
                    return("没有找到这个词条哦~");
                }
            }
        }
示例#16
0
        //http://www.cnblogs.com/lianmin/p/4257421.html
        /// 发送好友消息
        public static bool SendMessageToFriend(string uid, string content, string specialMessage = "")
        {
            if (content.Equals(""))
            {
                return(false);
            }
            if (uid.Equals(""))
            {
                return(false);
            }
            string[] temp = specialMessage.Split(',');;
            MsgId++;
            content = content.Replace("\r\n", "\n");
            content = content.Replace("\n\r", "\n");
            content = content.Replace("\r", "\n");
            content = content.Replace("\n", Environment.NewLine);
            try
            {
                string postData = "";
                if (temp[0] != "disscuss")
                {
                    postData = "{\"to\":" + uid;
                }
                else
                {
                    postData = "{\"did\":" + uid;
                }
                postData += ",\"content\":\"[" + content.Replace(Environment.NewLine, "\\\\n");
                postData += ",[\\\"font\\\",{\\\"name\\\":\\\"宋体\\\",\\\"size\\\":10,\\\"style\\\":[0,0,0],\\\"color\\\":\\\"000000\\\"}]]\",\"clientid\":" + ClientID + ",\"face\":";
                postData += "0";
                postData += ",\"msg_id\":" + MsgId;
                postData += ",\"psessionid\":\"" + psessionid + "\"";

                if (temp[0] != "" && temp[0] != "disscuss")
                {
                    postData += ",\"group_sig\":\"" + GetGroupSig(temp[0], temp[1], temp[2]);
                    postData += "\",\"service_type\":" + temp[2];
                }
                postData += "}";
                string url;
                string referer = "http://d1.web2.qq.com/proxy.html?v=20151105001&callback=1&id=2";
                if (specialMessage == "")
                {
                    url = "http://d1.web2.qq.com/channel/send_buddy_msg2";
                }
                else if (temp[0] == "disscuss")
                {
                    url = "http://d1.web2.qq.com/channel/send_discu_msg2";
                }
                else
                {
                    url = "http://d1.web2.qq.com/channel/send_sess_msg2";
                }
                postData = "r=" + HttpUtility.UrlEncode(postData);

                string dat = HTTP.HttpPost(url, referer, postData, Encoding.UTF8, false);

                dat = dat.Replace("{\"retcode\":", "");
                dat = dat.Replace("\"result\":\"", "");
                dat = dat.Replace("\"}", "");
                string[] tmp = dat.Split(',');
                if (tmp[0] == "0" && tmp[0] == "ok")
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch
            {
                return(false);
            }
        }
示例#17
0
        public static string GetWeather(string city, string target)
        {
            if ((!city.Equals("呼市郊区")) && (!city.Equals("津市")) && (!city.Equals("沙市")))
            {
                city = city.Replace("省", "");
                city = city.Replace("市", "");
            }
            city = city.Replace(" ", "");
            city = city.Replace("\r", "");
            city = city.Replace("\n", "");

            target = target.Replace(" ", "");
            target = target.Replace("\r", "");
            target = target.Replace("\n", "");
            string ans = "";
            string url, temp;

            if (target.Equals("雅虎"))
            {
                url  = "https://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20weather.forecast%20where%20woeid%20in%20%28select%20woeid%20from%20geo.places%281%29%20where%20text=\"" + city + "\") and%20u=%22c%22&format=json";
                temp = HTTP.HttpGet(url);
                JsonYahooWeatherModel weather = (JsonYahooWeatherModel)JsonConvert.DeserializeObject(temp, typeof(JsonYahooWeatherModel));
                if (weather.query.results == null)
                {
                    return("未查询到指定城市 " + city + " 的天气信息");
                }
                else
                {
                    ans = weather.query.results.channel.description + "(请核对城市名是否正确)";
                    for (int i = 0; i < weather.query.results.channel.item.forecast.Count; i++)
                    {
                        ans = ans + Environment.NewLine + "周" + getYahooWeak(weather.query.results.channel.item.forecast[i].day) + ":" + getYahooWeatherCode(weather.query.results.channel.item.forecast[i].code) + ",最高气温:" + weather.query.results.channel.item.forecast[i].high + "摄氏度,最低气温:" + weather.query.results.channel.item.forecast[i].low + "摄氏度";
                    }
                    return(ans);
                }
            }
            if (target.Equals("指数"))
            {
                target = "index";
            }
            else
            {
                target = "forecast";
            }
            url  = "https://ruiruiqq.hxlxz.com/weather.php?city=" + city + "&type=" + target;
            temp = HTTP.HttpGet(url);
            if (temp.Equals("NoCity"))
            {
                return(GetWeather(city, "雅虎"));
            }

            if (target.Equals("forecast"))
            {
                JsonWeatherModel weather = (JsonWeatherModel)JsonConvert.DeserializeObject(temp, typeof(JsonWeatherModel));
                ans = "根据中国天气网于" + weather.f.f0 + "发布的气象预报," + weather.c.c3 + "的气象信息如下:" + Environment.NewLine;
                if (weather.f.f1[0].fa != null && !weather.f.f1[0].fa.Equals(""))
                {
                    ans = ans + "今天白天:" + SloveWeather(weather.f.f1[0].fa) + "," + weather.f.f1[0].fc + "摄氏度," + SloveWind(weather.f.f1[0].fe) + SloveWindPower(weather.f.f1[0].fg) + "。";
                }
                else
                {
                    ans = ans + "今天";
                }
                ans = ans + "晚上:" + SloveWeather(weather.f.f1[0].fb) + "," + weather.f.f1[0].fd + "摄氏度," + SloveWind(weather.f.f1[0].ff) + SloveWindPower(weather.f.f1[0].fh) + "。日出日落时间:" + weather.f.f1[0].fi + Environment.NewLine;
                ans = ans + "明天白天:" + SloveWeather(weather.f.f1[1].fa) + "," + weather.f.f1[1].fc + "摄氏度," + SloveWind(weather.f.f1[1].fe) + SloveWindPower(weather.f.f1[1].fg) + "。";
                ans = ans + "晚上:" + SloveWeather(weather.f.f1[1].fb) + "," + weather.f.f1[1].fd + "摄氏度," + SloveWind(weather.f.f1[1].ff) + SloveWindPower(weather.f.f1[1].fh) + "。日出日落时间:" + weather.f.f1[1].fi + Environment.NewLine;
                ans = ans + "后天白天:" + SloveWeather(weather.f.f1[2].fa) + "," + weather.f.f1[2].fc + "摄氏度," + SloveWind(weather.f.f1[2].fe) + SloveWindPower(weather.f.f1[2].fg) + "。";
                ans = ans + "晚上:" + SloveWeather(weather.f.f1[2].fb) + "," + weather.f.f1[2].fd + "摄氏度," + SloveWind(weather.f.f1[2].ff) + SloveWindPower(weather.f.f1[2].fh) + "。日出日落时间:" + weather.f.f1[2].fi;
            }
            else if (target.Equals("index"))
            {
                JsonWeatherIndexModel WeatherIndex = (JsonWeatherIndexModel)JsonConvert.DeserializeObject(temp, typeof(JsonWeatherIndexModel));
                ans = "根据中国天气网发布的气象预报," + city + "的气象信息如下:" + Environment.NewLine;
                ans = ans + WeatherIndex.i[0].i2 + ":" + WeatherIndex.i[0].i4 + ";" + WeatherIndex.i[0].i5 + Environment.NewLine;
                ans = ans + WeatherIndex.i[1].i2 + ":" + WeatherIndex.i[1].i4 + ";" + WeatherIndex.i[1].i5 + Environment.NewLine;
                ans = ans + WeatherIndex.i[2].i2 + ":" + WeatherIndex.i[2].i4 + ";" + WeatherIndex.i[2].i5;
            }
            return(ans);
        }
示例#18
0
        public static string GetStock(string p1, string p2 = "")
        {
            string url = "";

            p1 = p1.Replace(" ", "");
            p1 = p1.Replace("\r", "");
            p1 = p1.Replace("\n", "");
            if (!p2.Equals(""))
            {
                p2 = p2.Replace(" ", "");
                p2 = p2.Replace("\r", "");
                p2 = p2.Replace("\n", "");
            }
            switch (p1)
            {
            case ("上证指数"): url = "http://hq.sinajs.cn/list=s_sh000001"; break;

            case ("深证综指"): url = "http://hq.sinajs.cn/list=s_sz399106"; break;

            case ("中小板指数"): url = "http://hq.sinajs.cn/list=s_sz399005"; break;

            case ("创业板指数"): url = "http://hq.sinajs.cn/list=s_sz399006"; break;

            case ("深证成指"): url = "http://hq.sinajs.cn/list=s_sz399001"; break;

            case ("中小板综指"): url = "http://hq.sinajs.cn/list=s_sz399101"; break;

            case ("创业板综指"): url = "http://hq.sinajs.cn/list=s_sz399102"; break;

            default:
            {
                if (p1.ToCharArray()[0] == '6')
                {
                    url = "http://hq.sinajs.cn/list=s_sh" + p1;
                }
                else if (p1.ToCharArray()[0] == '0' || p1.ToCharArray()[0] == '3')
                {
                    url = "http://hq.sinajs.cn/list=s_sz" + p1;
                }
                else if (p1.Equals("上海") || p1.Equals("沪市") || p1.Equals("上证"))
                {
                    url = "http://hq.sinajs.cn/list=s_sh" + p2;
                }
                else if (p1.Equals("深圳") || p1.Equals("深市") || p1.Equals("深证") || p1.Equals("创业板") || p1.Equals("中小板"))
                {
                    url = "http://hq.sinajs.cn/list=s_sz" + p2;
                }
                else
                {
                    return("参数错误");
                }
                break;
            }
            }
            string dat = HTTP.HttpGet(url, 100000, Encoding.GetEncoding("GB2312"));

            string[] tmp = dat.Split('\"');
            tmp = tmp[1].Split(',');
            if (tmp.Length == 1)
            {
                return("参数错误");
            }
            string ans = "根据新浪财经的信息," + tmp[0] + ":现价," + tmp[1] + ";涨跌" + tmp[2] + "," + tmp[3] + "%;成交量," + tmp[4] + "手," + tmp[5] + "万元。";

            return(ans);
        }