Exemplo n.º 1
0
        private string GetSign(string URI, string paras, string httptype, AppEnum.Apps app)
        {
            StringBuilder builder = new StringBuilder();

            builder.Append(httptype).Append(HttpUtility.UrlEncode(URI)).Append(HttpUtility.UrlEncode(paras));
            HMACSHA1 hmacsha = new HMACSHA1
            {
                Key = Encoding.ASCII.GetBytes(AppConfig.QQWeiBoAppSecret()[(int)app])
            };

            byte[] bytes = Encoding.ASCII.GetBytes(builder.ToString());
            return(Convert.ToBase64String(hmacsha.ComputeHash(bytes)));
        }
Exemplo n.º 2
0
        public bool CheckFriend(string openid, string openkey, string ip, AppEnum.Apps app)
        {
            bool flag = false;
            SortedDictionary <string, string> dictionary = new SortedDictionary <string, string>();

            dictionary.Add("format", "xml");
            dictionary.Add("names", "iamsnowsnow");
            dictionary.Add("flag", "1");
            dictionary.Add("appid", AppConfig.QQWeiBoAppID()[(int)app]);
            dictionary.Add("openid", openid);
            dictionary.Add("openkey", openkey);
            dictionary.Add("clientip", ip);
            TimeSpan span = new TimeSpan(DateTime.Now.Ticks);

            dictionary.Add("reqtime", ((int)Math.Floor(span.TotalSeconds)).ToString());
            dictionary.Add("wbversion", "1");
            string paras = "";

            foreach (KeyValuePair <string, string> pair in dictionary)
            {
                string str3 = paras;
                paras = str3 + pair.Key + "=" + pair.Value + "&";
            }
            paras.Remove(paras.Length - 1);
            paras = "http://open.t.qq.com/api/friends/check?" + paras + "&sig=" + this.GetSign("friends/check", paras, "GET", app);
            string      xml      = this.HttpGet(paras, "utf-8");
            XmlDocument document = new XmlDocument();

            document.LoadXml(xml);
            if (document != null)
            {
                XmlNode node = document.SelectSingleNode("//root");
                if (node == null)
                {
                    return(flag);
                }
                if (node.SelectSingleNode("//ret").InnerXml != "0")
                {
                    return(flag);
                }
                if (node.SelectSingleNode("//data").FirstChild.InnerXml == "true")
                {
                    flag = true;
                }
            }
            return(flag);
        }
Exemplo n.º 3
0
        public string GetUserSimpleInfo(string openid, string openkey, string ip, AppEnum.Apps app)
        {
            string str = "|||0|0";
            SortedDictionary <string, string> dictionary = new SortedDictionary <string, string>();

            dictionary.Add("format", "xml");
            dictionary.Add("appid", AppConfig.QQWeiBoAppID()[(int)app]);
            dictionary.Add("openid", openid);
            dictionary.Add("openkey", openkey);
            dictionary.Add("clientip", ip);
            TimeSpan span = new TimeSpan(DateTime.Now.Ticks);

            dictionary.Add("reqtime", ((int)Math.Floor(span.TotalSeconds)).ToString());
            dictionary.Add("wbversion", "1");
            string paras = "";

            foreach (KeyValuePair <string, string> pair in dictionary)
            {
                string str4 = paras;
                paras = str4 + pair.Key + "=" + pair.Value + "&";
            }
            paras.Remove(paras.Length - 1);
            paras = "http://open.t.qq.com/api/user/info?" + paras + "&sig=" + this.GetSign("user/info", paras, "GET", app);
            string      xml      = this.HttpGet(paras, "utf-8");
            XmlDocument document = new XmlDocument();

            document.LoadXml(xml);
            if (document == null)
            {
                return(str);
            }
            XmlNode node = document.SelectSingleNode("//root");

            if (node == null)
            {
                return(str);
            }
            if (node.SelectSingleNode("//ret").InnerXml != "0")
            {
                return(str);
            }
            XmlNode node2 = node.SelectSingleNode("//data");

            return(node2.SelectSingleNode("//name").InnerXml + "|" + node2.SelectSingleNode("//nick").InnerXml + "|" + node2.SelectSingleNode("//location").InnerXml + "|" + node2.SelectSingleNode("//fansnum").InnerXml + "|" + node2.SelectSingleNode("//isvip").InnerXml + "|" + node2.SelectSingleNode("//head").InnerXml + "|" + node2.SelectSingleNode("//introduction").InnerXml + "|" + node2.SelectSingleNode("//sex").InnerXml);
        }
Exemplo n.º 4
0
        public bool CheckFriend(string openid, string accesstoken, string ip, AppEnum.Apps app, bool isaccesstoken)
        {
            bool flag = false;
            SortedDictionary <string, string> dictionary = new SortedDictionary <string, string>();

            dictionary.Add("format", "xml");
            dictionary.Add("names", "iamsnowsnow");
            dictionary.Add("flag", "1");
            dictionary.Add("oauth_consumer_key", AppConfig.QQWeiBoAppID()[(int)app]);
            dictionary.Add("openid", openid);
            dictionary.Add("access_token", accesstoken);
            dictionary.Add("clientip", ip);
            dictionary.Add("oauth_version", "2.a");
            dictionary.Add("scope", "all");
            string str = "";

            foreach (KeyValuePair <string, string> pair in dictionary)
            {
                string str3 = str;
                str = str3 + pair.Key + "=" + pair.Value + "&";
            }
            str.Remove(str.Length - 1);
            str = "https://open.t.qq.com/api/friends/check?" + str;
            string      xml      = this.HttpGet(str, "utf-8");
            XmlDocument document = new XmlDocument();

            document.LoadXml(xml);
            if (document != null)
            {
                XmlNode node = document.SelectSingleNode("//root");
                if (node == null)
                {
                    return(flag);
                }
                if (node.SelectSingleNode("//ret").InnerXml != "0")
                {
                    return(flag);
                }
                if (node.SelectSingleNode("//data").FirstChild.InnerXml == "true")
                {
                    flag = true;
                }
            }
            return(flag);
        }
Exemplo n.º 5
0
        public bool AddFriend(string openid, string accesstoken, string ip, string name, AppEnum.Apps app, bool isaccesstoken)
        {
            bool flag = false;
            SortedDictionary <string, string> dictionary = new SortedDictionary <string, string>();

            dictionary.Add("format", "xml");
            dictionary.Add("name", name);
            dictionary.Add("oauth_consumer_key", AppConfig.QQWeiBoAppID()[(int)app]);
            dictionary.Add("openid", openid);
            dictionary.Add("access_token", accesstoken);
            dictionary.Add("clientip", ip);
            dictionary.Add("oauth_version", "2.a");
            dictionary.Add("scope", "all");
            string str = "";

            foreach (KeyValuePair <string, string> pair in dictionary)
            {
                string str3 = str;
                str = str3 + pair.Key + "=" + pair.Value + "&";
            }
            str.Remove(str.Length - 1);
            string      xml      = this.HttpPost(HttpUtility.UrlPathEncode(str), "https://open.t.qq.com/api/friends/add", "utf-8");
            XmlDocument document = new XmlDocument();

            document.LoadXml(xml);
            if (document != null)
            {
                XmlNode node = document.SelectSingleNode("//root");
                if ((node != null) && (node.SelectSingleNode("//ret").InnerXml == "0"))
                {
                    flag = true;
                }
            }
            return(flag);
        }
Exemplo n.º 6
0
        public bool SendPicWeiBo(string openid, string openkey, string ip, string content, string pic, AppEnum.Apps app)
        {
            bool flag = false;
            SortedDictionary <string, string> dictionary = new SortedDictionary <string, string>();

            dictionary.Add("format", "xml");
            dictionary.Add("content", content);
            dictionary.Add("pic_url", pic);
            dictionary.Add("clientip", ip);
            dictionary.Add("appid", AppConfig.QQWeiBoAppID()[(int)app]);
            dictionary.Add("openid", openid);
            dictionary.Add("openkey", openkey);
            TimeSpan span = new TimeSpan(DateTime.Now.Ticks);

            dictionary.Add("reqtime", ((int)Math.Floor(span.TotalSeconds)).ToString());
            dictionary.Add("wbversion", "1");
            string paras = "";

            foreach (KeyValuePair <string, string> pair in dictionary)
            {
                string str3 = paras;
                paras = str3 + pair.Key + "=" + pair.Value + "&";
            }
            paras.Remove(paras.Length - 1);
            paras = paras + "&sig=" + this.GetSign("t/add_pic_url", paras, "POST", app);
            string      xml      = this.HttpPost(HttpUtility.UrlPathEncode(paras), "http://open.t.qq.com/api/t/add_pic_url", "utf-8");
            XmlDocument document = new XmlDocument();

            document.LoadXml(xml);
            if (document != null)
            {
                XmlNode node = document.SelectSingleNode("//root");
                if ((node != null) && (node.SelectSingleNode("//ret").InnerXml == "0"))
                {
                    flag = true;
                }
            }
            return(flag);
        }
Exemplo n.º 7
0
        public XmlDocument GetTopicList(string openid, string openkey, string ip, string name, int type, AppEnum.Apps app)
        {
            SortedDictionary <string, string> dictionary = new SortedDictionary <string, string>();

            dictionary.Add("format", "xml");
            dictionary.Add("httext", name);
            dictionary.Add("htid", "0");
            dictionary.Add("type", type.ToString());
            dictionary.Add("pageflag", "0");
            dictionary.Add("flag", "0");
            dictionary.Add("time", "0");
            dictionary.Add("reqnum", "100");
            dictionary.Add("tweetid ", "0");
            dictionary.Add("contenttype", "0");
            dictionary.Add("clientip", ip);
            dictionary.Add("appid", AppConfig.QQWeiBoAppID()[(int)app]);
            dictionary.Add("openid", openid);
            dictionary.Add("openkey", openkey);
            TimeSpan span = new TimeSpan(DateTime.Now.Ticks);

            dictionary.Add("reqtime", ((int)Math.Floor(span.TotalSeconds)).ToString());
            dictionary.Add("wbversion", "1");
            string paras = "";

            foreach (KeyValuePair <string, string> pair in dictionary)
            {
                string str3 = paras;
                paras = str3 + pair.Key + "=" + pair.Value + "&";
            }
            paras.Remove(paras.Length - 1);
            string      xml      = this.HttpGet("https://open.t.qq.com/api/statuses/ht_timeline_ext?" + (paras + "&sig=" + this.GetSign("statuses/user_timeline", paras, "GET", app)), "utf-8");
            XmlDocument document = new XmlDocument();

            document.LoadXml(xml);
            if (document == null)
            {
                return(null);
            }
            return(document);
        }
Exemplo n.º 8
0
        public string GetUserSimpleInfo(string openid, string accesstoken, string ip, AppEnum.Apps app, bool isaccesstoken)
        {
            string str = "|||0|0";
            SortedDictionary <string, string> dictionary = new SortedDictionary <string, string>();

            dictionary.Add("format", "xml");
            dictionary.Add("oauth_consumer_key", AppConfig.QQWeiBoAppID()[(int)app]);
            dictionary.Add("openid", openid);
            dictionary.Add("access_token", accesstoken);
            dictionary.Add("clientip", ip);
            dictionary.Add("oauth_version", "2.a");
            dictionary.Add("scope", "all");
            string str2 = "";

            foreach (KeyValuePair <string, string> pair in dictionary)
            {
                string str4 = str2;
                str2 = str4 + pair.Key + "=" + pair.Value + "&";
            }
            str2.Remove(str2.Length - 1);
            str2 = "https://open.t.qq.com/api/user/info?" + str2;
            string      xml      = this.HttpGet(str2, "utf-8");
            XmlDocument document = new XmlDocument();

            document.LoadXml(xml);
            if (document == null)
            {
                return(str);
            }
            XmlNode node = document.SelectSingleNode("//root");

            if (node == null)
            {
                return(str);
            }
            if (node.SelectSingleNode("//ret").InnerXml != "0")
            {
                return(str);
            }
            XmlNode node2 = node.SelectSingleNode("//data");

            return(node2.SelectSingleNode("//name").InnerXml + "|" + node2.SelectSingleNode("//nick").InnerXml + "|" + node2.SelectSingleNode("//location").InnerXml + "|" + node2.SelectSingleNode("//fansnum").InnerXml + "|" + node2.SelectSingleNode("//isvip").InnerXml + "|" + node2.SelectSingleNode("//head").InnerXml + "|" + node2.SelectSingleNode("//introduction").InnerXml + "|" + node2.SelectSingleNode("//sex").InnerXml);
        }
Exemplo n.º 9
0
        public DataTable GetReList(string openid, string openkey, string ip, int rootid, int type, AppEnum.Apps app)
        {
            DataTable table = new DataTable();
            SortedDictionary <string, string> dictionary = new SortedDictionary <string, string>();

            dictionary.Add("format", "xml");
            dictionary.Add("rootid", rootid.ToString());
            dictionary.Add("flag", type.ToString());
            dictionary.Add("pageflag", "0");
            dictionary.Add("pagetime", "0");
            dictionary.Add("reqnum", "100");
            dictionary.Add("twitterid", "0");
            dictionary.Add("clientip", ip);
            dictionary.Add("appid", AppConfig.QQWeiBoAppID()[(int)app]);
            dictionary.Add("openid", openid);
            dictionary.Add("openkey", openkey);
            TimeSpan span = new TimeSpan(DateTime.Now.Ticks);

            dictionary.Add("reqtime", ((int)Math.Floor(span.TotalSeconds)).ToString());
            dictionary.Add("wbversion", "1");
            string paras = "";

            foreach (KeyValuePair <string, string> pair in dictionary)
            {
                string str3 = paras;
                paras = str3 + pair.Key + "=" + pair.Value + "&";
            }
            paras.Remove(paras.Length - 1);
            paras = paras + "&sig=" + this.GetSign("t/re_list", paras, "POST", app);
            string      xml      = this.HttpPost(HttpUtility.UrlPathEncode(paras), "https://open.t.qq.com/api/t/re_list", "utf-8");
            XmlDocument document = new XmlDocument();

            document.LoadXml(xml);
            if (document != null)
            {
                XmlNode node = document.SelectSingleNode("//root");
                if (node != null)
                {
                    bool flag1 = node.SelectSingleNode("//ret").InnerXml == "0";
                }
            }
            return(table);
        }