예제 #1
0
        /// <summary>
        /// 取授权登录URL
        /// </summary>
        /// <returns>登录URL</returns>
        public string GetAuthUrl()
        {
            //http://wiki.open.kaixin001.com/index.php?id=OAuth%e6%96%87%e6%a1%a3
            List <UrlParameter> param = new List <UrlParameter>();

            param.Add(new UrlParameter("oauth_callback", config.RedirectUrl.UrlEncode2()));
            param.Add(new UrlParameter("oauth_consumer_key", config.AppKey));
            param.Add(new UrlParameter("oauth_nonce", OAuthCommon.GetGUID32()));
            param.Add(new UrlParameter("oauth_signature_method", "HMAC-SHA1"));
            param.Add(new UrlParameter("oauth_timestamp", OAuthCommon.GetTimestamp()));
            param.Add(new UrlParameter("oauth_version", "1.0"));
            param.Add(new UrlParameter("scope", "create_records"));
            param.Sort(new UrlParameterCompre());

            StringBuilder sbSign = new StringBuilder().Append("GET&")
                                   .Append(request_token.UrlEncode2())
                                   .Append("&")
                                   .Append(OAuthCommon.GetUrlParameter(param).UrlEncode2());

            param.Add(new UrlParameter("oauth_signature", OAuthCommon.GetHMACSHA1(config.AppSecret, "", sbSign.ToString()).UrlEncode2()));
            param.Sort(new UrlParameterCompre());

            string data = HttpHelper.SendGet(new StringBuilder().Append(request_token).Append("?").Append(OAuthCommon.GetUrlParameter(param)).ToString());

            string token       = data.GetMatchingValues("oauth_token=(.+?)&", "oauth_token=", "&").FirstOrDefault() ?? "";
            string tokenSecret = data.GetMatchingValues("oauth_token_secret=(.+?)&", "oauth_token_secret=", "&").FirstOrDefault() ?? "";

            Session2.Set("oauth_token", token);
            Session2.Set("oauth_token_secret", tokenSecret);
            return(authorize + "?oauth_token=" + token);
        }
예제 #2
0
        /// <summary>
        /// 取登录账号信息
        /// </summary>
        /// <returns>取登录账号信息</returns>
        public UserInfo GetUserInfo()
        {
            UserInfo user    = new UserInfo();
            string   openid  = Request2.GetQ("openid");
            string   openkey = Request2.GetQ("openkey");

            List <UrlParameter> param = new List <UrlParameter>();

            param.Add(new UrlParameter("oauth_consumer_key", config.AppKey));
            param.Add(new UrlParameter("oauth_nonce", OAuthCommon.GetGUID32()));
            param.Add(new UrlParameter("oauth_signature_method", "HMAC-SHA1"));
            param.Add(new UrlParameter("oauth_timestamp", OAuthCommon.GetTimestamp()));
            param.Add(new UrlParameter("oauth_token", Request2.GetQ("oauth_token")));
            param.Add(new UrlParameter("oauth_verifier", Request2.GetQ("oauth_verifier")));
            param.Add(new UrlParameter("oauth_version", "1.0"));
            //param.Add(new UrlParameter("scope", "create_records"));
            param.Sort(new UrlParameterCompre());

            StringBuilder sbSign = new StringBuilder().Append("GET&")
                                   .Append(access_token.UrlEncode2())
                                   .Append("&")
                                   .Append(OAuthCommon.GetUrlParameter(param).UrlEncode2());

            param.Add(new UrlParameter("oauth_signature", OAuthCommon.GetHMACSHA1(config.AppSecret, Session2.Get("oauth_token_secret"), sbSign.ToString()).UrlEncode2()));
            param.Sort(new UrlParameterCompre());
            string data = HttpHelper.SendGet(new StringBuilder().Append(access_token).Append("?").Append(OAuthCommon.GetUrlParameter(param)).ToString()) + "&";

            user.Token  = data.GetMatchingValues("oauth_token=(.+?)&", "oauth_token=", "&").FirstOrDefault() ?? "";
            user.Secret = data.GetMatchingValues("oauth_token_secret=(.+?)&", "oauth_token_secret=", "&").FirstOrDefault() ?? "";

            param.Clear();
            param.Add(new UrlParameter("oauth_consumer_key", config.AppKey));
            param.Add(new UrlParameter("oauth_nonce", OAuthCommon.GetGUID32()));
            param.Add(new UrlParameter("oauth_signature_method", "HMAC-SHA1"));
            param.Add(new UrlParameter("oauth_timestamp", OAuthCommon.GetTimestamp()));
            param.Add(new UrlParameter("oauth_token", user.Token));
            param.Add(new UrlParameter("oauth_version", "1.0"));
            //param.Add(new UrlParameter("scope", "create_records"));
            param.Sort(new UrlParameterCompre());

            StringBuilder sbSign2 = new StringBuilder().Append("GET&")
                                    .Append(user_info.UrlEncode2())
                                    .Append("&")
                                    .Append(OAuthCommon.GetUrlParameter(param).UrlEncode2());

            param.Add(new UrlParameter("oauth_signature", OAuthCommon.GetHMACSHA1(config.AppSecret, user.Secret, sbSign2.ToString()).UrlEncode2()));
            param.Sort(new UrlParameterCompre());
            data = HttpHelper.SendGet(new StringBuilder().Append(user_info).Append("?").Append(OAuthCommon.GetUrlParameter(param)).ToString());

            user.UserID = data.GetMatchingValues("\"uid\":\"(.+?)\"", "\"uid\":\"", "\"").FirstOrDefault() ?? "";
            user.Email  = data.GetMatchingValues("\"email\":\"(.+?)\"", "\"email\":\"", "\"").FirstOrDefault() ?? "";
            user.Name   = (data.GetMatchingValues("\"name\":\"(.+?)\"", "\"name\":\"", "\"").FirstOrDefault() ?? "").Ascii2Native();
            user.Sex    = (data.GetMatchingValues("\"gender\":\"(.+?)\"", "\"gender\":\"", "\"").FirstOrDefault() ?? "") == "0" ? 1 : 0;
            user.Header = data.GetMatchingValues("\"logo50\":\"(.+?)\"", "\"logo50\":\"", "\"").FirstOrDefault() ?? "";

            //{"uid":"45908241","name":"\u534e\u6625","gender":"0","logo50":"http:\/\/img.kaixin001.com.cn\/i\/50_0_0.gif"}
            //Msg.WriteEnd(GetFriendsInfo(user.Token, user.Secret).ToJson());
            //SendText(user.Token, user.Secret, "测试数据");
            return(user);
        }
예제 #3
0
        /// <summary>
        /// 同步消息
        /// </summary>
        /// <param name="accessToken">Access Token</param>
        /// <param name="accessSecret">Access Secret</param>
        /// <param name="text">消息</param>
        public void SendText(string accessToken, string accessSecret, string text)
        {
            List <UrlParameter> param = new List <UrlParameter>();

            param.Add(new UrlParameter("oauth_consumer_key", config.AppKey));
            param.Add(new UrlParameter("oauth_nonce", OAuthCommon.GetGUID32()));
            param.Add(new UrlParameter("oauth_signature_method", "HMAC-SHA1"));
            param.Add(new UrlParameter("oauth_timestamp", OAuthCommon.GetTimestamp()));
            param.Add(new UrlParameter("oauth_token", accessToken));
            param.Add(new UrlParameter("oauth_version", "1.0"));
            param.Add(new UrlParameter("format", "json"));
            param.Add(new UrlParameter("content", text.SubString(270, "").UrlUpperEncode()));
            //param.Add(new UrlParameter("clientip", "127.0.0.1"));
            //param.Add(new UrlParameter("jing", ""));
            //param.Add(new UrlParameter("wei", ""));
            param.Sort(new UrlParameterCompre());

            StringBuilder sbSign = new StringBuilder().Append("POST&")
                                   .Append(add.UrlEncode2())
                                   .Append("&")
                                   .Append(OAuthCommon.GetUrlParameter(param).UrlEncode2());

            param.Add(new UrlParameter("oauth_signature", OAuthCommon.GetHMACSHA1(config.AppSecret, accessSecret, sbSign.ToString()).UrlEncode2()));
            param.Sort(new UrlParameterCompre());
            HttpHelper.SendPost(add, OAuthCommon.GetUrlParameter(param));
        }
예제 #4
0
        /// <summary>
        /// 取授权登录URL
        /// </summary>
        /// <returns>登录URL</returns>
        public string GetAuthUrl()
        {
            List <UrlParameter> param = new List <UrlParameter>();

            param.Add(new UrlParameter("oauth_consumer_key", config.AppKey));
            param.Add(new UrlParameter("oauth_nonce", OAuthCommon.GetGUID32()));
            param.Add(new UrlParameter("oauth_signature_method", "HMAC-SHA1"));
            param.Add(new UrlParameter("oauth_timestamp", OAuthCommon.GetTimestamp()));
            param.Add(new UrlParameter("oauth_version", "1.0"));
            param.Sort(new UrlParameterCompre());

            StringBuilder sbSign = new StringBuilder().Append("GET&")
                                   .Append(request_token.UrlEncode2())
                                   .Append("&")
                                   .Append(OAuthCommon.GetUrlParameter(param).UrlEncode2());

            param.Add(new UrlParameter("oauth_signature", OAuthCommon.GetHMACSHA1(config.AppSecret, "", sbSign.ToString()).UrlEncode2()));
            param.Sort(new UrlParameterCompre());
            string data = HttpHelper.SendGet(new StringBuilder().Append(request_token).Append("?").Append(OAuthCommon.GetUrlParameter(param)).ToString());

            int    intOTS             = data.IndexOf("oauth_token=");
            int    intOTSS            = data.IndexOf("&oauth_token_secret=");
            string oauth_token        = data.Substring(intOTS + 12, intOTSS - (intOTS + 12));
            string oauth_token_secret = data.Substring((intOTSS + 20), data.Length - (intOTSS + 20));

            Session2.Set("oauth_token", oauth_token);
            Session2.Set("oauth_token_secret", oauth_token_secret);
            return(authorize + "?oauth_token=" + oauth_token + "&oauth_callback=" + config.RedirectUrl);
        }
예제 #5
0
        /// <summary>
        /// 取登录账号信息
        /// </summary>
        /// <returns>取登录账号信息</returns>
        public UserInfo GetUserInfo()
        {
            UserInfo user    = new UserInfo();
            string   openid  = Request2.GetQ("openid");
            string   openkey = Request2.GetQ("openkey");

            List <UrlParameter> param = new List <UrlParameter>();

            param.Add(new UrlParameter("oauth_consumer_key", config.AppKey));
            param.Add(new UrlParameter("oauth_nonce", OAuthCommon.GetGUID32()));
            param.Add(new UrlParameter("oauth_signature_method", "HMAC-SHA1"));
            param.Add(new UrlParameter("oauth_timestamp", OAuthCommon.GetTimestamp()));
            param.Add(new UrlParameter("oauth_token", Request2.GetQ("oauth_token")));
            param.Add(new UrlParameter("oauth_verifier", Request2.GetQ("oauth_verifier")));
            param.Add(new UrlParameter("oauth_version", "1.0"));
            param.Sort(new UrlParameterCompre());

            StringBuilder sbSign = new StringBuilder().Append("GET&")
                                   .Append(access_token.UrlEncode2())
                                   .Append("&")
                                   .Append(OAuthCommon.GetUrlParameter(param).UrlEncode2());

            param.Add(new UrlParameter("oauth_signature", OAuthCommon.GetHMACSHA1(config.AppSecret, Session2.Get("oauth_token_secret"), sbSign.ToString()).UrlEncode2()));
            param.Sort(new UrlParameterCompre());
            string data = HttpHelper.SendGet(new StringBuilder().Append(access_token).Append("?").Append(OAuthCommon.GetUrlParameter(param)).ToString());

            user.Token  = data.GetMatchingValues("oauth_token=(.+?)&", "oauth_token=", "&").FirstOrDefault() ?? "";
            user.Secret = data.GetMatchingValues("oauth_token_secret=(.+?)&", "oauth_token_secret=", "&").FirstOrDefault() ?? "";
            user.UserID = data.Substring(data.IndexOf("&name=") + 6);

            param.Clear();
            param.Add(new UrlParameter("oauth_consumer_key", config.AppKey));
            param.Add(new UrlParameter("oauth_nonce", OAuthCommon.GetGUID32()));
            param.Add(new UrlParameter("oauth_signature_method", "HMAC-SHA1"));
            param.Add(new UrlParameter("oauth_timestamp", OAuthCommon.GetTimestamp()));
            param.Add(new UrlParameter("oauth_token", user.Token));
            param.Add(new UrlParameter("oauth_version", "1.0"));
            param.Add(new UrlParameter("format", "json"));
            param.Sort(new UrlParameterCompre());

            StringBuilder sbSign2 = new StringBuilder().Append("GET&")
                                    .Append(user_info.UrlEncode2())
                                    .Append("&")
                                    .Append(OAuthCommon.GetUrlParameter(param).UrlEncode2());

            param.Add(new UrlParameter("oauth_signature", OAuthCommon.GetHMACSHA1(config.AppSecret, user.Secret, sbSign2.ToString()).UrlEncode2()));
            param.Sort(new UrlParameterCompre());
            data = HttpHelper.SendGet(new StringBuilder().Append(user_info).Append("?").Append(OAuthCommon.GetUrlParameter(param)).ToString());

            user.Email   = data.GetMatchingValues("\"email\":\"(.+?)\"", "\"email\":\"", "\"").FirstOrDefault() ?? "";
            user.Name    = data.GetMatchingValues("\"nick\":\"(.+?)\"", "\"nick\":\"", "\"").FirstOrDefault() ?? "";
            user.Sex     = (data.GetMatchingValues("\"sex\":(.+?),", "\"sex\":", ",").FirstOrDefault() ?? "") == "1" ? 1 : 0;
            user.Address = data.GetMatchingValues("\"location\":\"(.+?)\"", "\"location\":\"", "\"").FirstOrDefault() ?? "";

            //{"data":{"birth_day":31,"birth_month":3,"birth_year":1984,"city_code":"9","country_code":"1","edu":null,"email":"*****@*****.**",
            //"fansnum":59,"head":"","idolnum":25,"introduction":"","isent":0,"isvip":0,"location":"未知","name":"cexo255","nick":"熊","openid":"",
            //"province_code":"31","sex":1,"tag":null,"tweetnum":40,"verifyinfo":""},"errcode":0,"msg":"ok","ret":0}
            //Msg.WriteEnd(GetFriendsInfo(user.Token, user.Secret).ToJson());
            return(user);
        }
예제 #6
0
        /// <summary>
        /// 取授权登录URL
        /// </summary>
        /// <returns>登录URL</returns>
        public string GetAuthUrl()
        {
            List <UrlParameter> param = new List <UrlParameter>();

            param.Add(new UrlParameter("oauth_consumer_key", config.AppKey));
            param.Add(new UrlParameter("oauth_nonce", OAuthCommon.GetGUID32()));
            param.Add(new UrlParameter("oauth_signature_method", "HMAC-SHA1"));
            param.Add(new UrlParameter("oauth_timestamp", OAuthCommon.GetTimestamp()));
            param.Add(new UrlParameter("oauth_version", "1.0"));
            param.Sort(new UrlParameterCompre());

            StringBuilder sbSign = new StringBuilder().Append("GET&")
                                   .Append(Rfc3986.Encode(request_token))
                                   .Append("&")
                                   .Append(Rfc3986.Encode(OAuthCommon.GetUrlParameter(param)));

            param.Add(new UrlParameter("oauth_signature", Rfc3986.Encode(OAuthCommon.GetHMACSHA1(Rfc3986.Encode(config.AppSecret), "", sbSign.ToString()))));
            param.Sort(new UrlParameterCompre());
            string data = HttpHelper.SendGet(new StringBuilder().Append(request_token).Append("?").Append(OAuthCommon.GetUrlParameter(param)).ToString()) + "&";

            string token       = data.GetMatchingValues("oauth_token=(.+?)&", "oauth_token=", "&").FirstOrDefault() ?? "";
            string tokenSecret = data.GetMatchingValues("oauth_token_secret=(.+?)&", "oauth_token_secret=", "&").FirstOrDefault() ?? "";

            Session2.Set("oauth_token", token);
            Session2.Set("oauth_token_secret", tokenSecret);
            return(authorize + "?oauth_token=" + token + "&oauth_callback=" + config.RedirectUrl);
        }
예제 #7
0
        /// <summary>
        /// 取登录账号好友信息
        /// </summary>
        /// <param name="accessToken">Access Token</param>
        /// <param name="accessSecret">Access Secret</param>
        /// <returns>取登录账号好友信息</returns>
        public IList <UserInfo> GetFriendsInfo(string accessToken, string accessSecret)
        {
            IList <UserInfo> list = new List <UserInfo>();
            bool             isTrue = true; int count = 10; int page = 1;

            while (isTrue)
            {
                List <UrlParameter> param = new List <UrlParameter>();
                param.Add(new UrlParameter("oauth_consumer_key", config.AppKey));
                param.Add(new UrlParameter("oauth_nonce", OAuthCommon.GetGUID32()));
                param.Add(new UrlParameter("oauth_signature_method", "HMAC-SHA1"));
                param.Add(new UrlParameter("oauth_timestamp", OAuthCommon.GetTimestamp()));
                param.Add(new UrlParameter("oauth_token", accessToken));
                param.Add(new UrlParameter("oauth_version", "1.0"));
                param.Add(new UrlParameter("fields", ""));
                param.Add(new UrlParameter("num", count));
                param.Add(new UrlParameter("start", count * (page - 1)));
                param.Sort(new UrlParameterCompre());

                StringBuilder sbSign = new StringBuilder().Append("GET&")
                                       .Append(friends_list.UrlEncode2())
                                       .Append("&")
                                       .Append(OAuthCommon.GetUrlParameter(param).UrlEncode2());

                param.Add(new UrlParameter("oauth_signature", OAuthCommon.GetHMACSHA1(config.AppSecret, accessSecret, sbSign.ToString()).UrlEncode2()));
                param.Sort(new UrlParameterCompre());
                string data = "";
                try {
                    data = HttpHelper.SendGet(new StringBuilder().Append(friends_list).Append("?").Append(OAuthCommon.GetUrlParameter(param)).ToString());
                    data = data.Substring(1, data.Length - 2);
                } catch {}
                IList <string> userlist = data.GetMatchingValues("{(.+?)}", "{", "}");

                foreach (string info in userlist)
                {
                    UserInfo user = new UserInfo();
                    user.UserID  = info.GetMatchingValues("\"uid\":\"(.+?)\"", "\"uid\":\"", "\"").FirstOrDefault() ?? "";
                    user.Email   = info.GetMatchingValues("\"email\":\"(.+?)\"", "\"email\":\"", "\"").FirstOrDefault() ?? "";
                    user.Name    = (info.GetMatchingValues("\"name\":\"(.+?)\"", "\"name\":\"", "\"").FirstOrDefault() ?? "").Ascii2Native();
                    user.Sex     = (info.GetMatchingValues("\"gender\":\"(.+?)\"", "\"gender\":\"", "\"").FirstOrDefault() ?? "") == "0" ? 1 : 0;
                    user.Address = info.GetMatchingValues("\"location\":\"(.+?)\"", "\"location\":\"", "\"").FirstOrDefault() ?? "";
                    user.Header  = info.GetMatchingValues("\"logo50\":\"(.+?)\"", "\"logo50\":\"", "\"").FirstOrDefault() ?? "";
                    list.Add(user);
                }

                if (userlist.IsNull() || userlist.Count == 0)
                {
                    isTrue = false;
                }
                page++;
            }
            ;

            //{"users":[
            //{"uid":"33941855","name":"\u65b0\u534e\u793e\u7535\u89c6","gender":"0","logo50":"http:\/\/logo.kaixin001.com.cn\/logo\/94\/18\/50_33941855_3.jpg"}],
            //"prev":"-1","next":"-1","total":"1"}
            return(list);
        }
예제 #8
0
        /// <summary>
        /// 取登录账号好友信息
        /// </summary>
        /// <param name="accessToken">Access Token</param>
        /// <param name="accessSecret">Access Secret</param>
        /// <returns>取登录账号好友信息</returns>
        public IList <UserInfo> GetFriendsInfo(string accessToken, string accessSecret)
        {
            IList <UserInfo> list = new List <UserInfo>();
            bool             isTrue = true; int count = 10; int page = 1;

            while (isTrue)
            {
                List <UrlParameter> param = new List <UrlParameter>();
                param.Add(new UrlParameter("oauth_consumer_key", config.AppKey));
                param.Add(new UrlParameter("oauth_nonce", OAuthCommon.GetGUID32()));
                param.Add(new UrlParameter("oauth_signature_method", "HMAC-SHA1"));
                param.Add(new UrlParameter("oauth_timestamp", OAuthCommon.GetTimestamp()));
                param.Add(new UrlParameter("oauth_token", accessToken));
                param.Add(new UrlParameter("oauth_version", "1.0"));
                param.Add(new UrlParameter("cursor", count * (page - 1)));
                param.Sort(new UrlParameterCompre());

                StringBuilder sbSign = new StringBuilder().Append("GET&")
                                       .Append(friends_list.UrlEncode2())
                                       .Append("&")
                                       .Append(OAuthCommon.GetUrlParameter(param).UrlEncode2());

                param.Add(new UrlParameter("oauth_signature", OAuthCommon.GetHMACSHA1(config.AppSecret, accessSecret, sbSign.ToString()).UrlEncode2()));
                param.Sort(new UrlParameterCompre());
                string data = "";
                try {
                    data = HttpHelper.SendGet(new StringBuilder().Append(friends_list).Append("?").Append(OAuthCommon.GetUrlParameter(param)).ToString());
                    data = data.Substring(1, data.Length - 2);
                } catch {}
                IList <string> userlist = data.GetMatchingValues("{\"status\":(.+?)]}", "{", "]}");

                foreach (string info in userlist)
                {
                    UserInfo user = new UserInfo();
                    user.UserID  = info.GetMatchingValues("\"id\":\"(.+?)\"", "\"id\":\"", "\"").FirstOrDefault() ?? "";
                    user.Email   = info.GetMatchingValues("\"email\":\"(.+?)\"", "\"email\":\"", "\"").FirstOrDefault() ?? "";
                    user.Name    = info.GetMatchingValues("\"name\":\"(.+?)\"", "\"name\":\"", "\"").FirstOrDefault() ?? "";
                    user.Sex     = (info.GetMatchingValues("\"gender\":\"(.+?)\"", "\"gender\":\"", "\"").FirstOrDefault() ?? "") == "1" ? 1 : 0;
                    user.Address = info.GetMatchingValues("\"location\":\"(.+?)\"", "\"location\":\"", "\"").FirstOrDefault() ?? "";
                    user.Header  = info.GetMatchingValues("\"profile_image_url\":\"(.+?)\"", "\"profile_image_url\":\"", "\"").FirstOrDefault() ?? "";
                    list.Add(user);
                }

                if (userlist.IsNull() || userlist.Count == 0)
                {
                    isTrue = false;
                }
                page++;
            }
            ;

            //"users":[
            //{"status":{"id":"-3707542760529240330","source":"网易微博","text":"","in_reply_to_screen_name":null,"in_reply_to_status_id":null,"in_reply_to_user_id":null,"in_reply_to_user_name":null,"truncated":false,"videoInfos":[{"title":"美国宪法和总统","flashUrl":"","coverUrl":"","shortUrl":"http://163.fm/EIPA0CD"}],"musicInfos":null},"following":true,"blocking":false,"followed_by":false,"name":"标尺的鲁克","location":",","id":"261087702224684492","description":"","email":"*****@*****.**","gender":"1","verified":false,"url":"http://dongxi.net/column/bc","screen_name":"lukepost","profile_image_url":"http://oimagec2.ydstatic.com/image?w=48&h=48&url=http%3A%2F%2F126.fm%2F2wLbCY","created_at":"Fri Sep 03 21:31:19 +0800 2010","darenRec":"标尺网专栏作者,美国问题专家","favourites_count":"31","followers_count":"426486","friends_count":"337","geo_enable":false,"icorp":"0","realName":null,"statuses_count":"2723","sysTag":["财经专栏"],"userTag":null,"in_groups":[]},
            //{"status":{"id":"5655595159751579198","source":"网易微博","text":"","created_at":"Fri Dec 09 11:18:44 +0800 2011","in_reply_to_screen_name":null,"in_reply_to_status_id":null,"in_reply_to_user_id":null,"in_reply_to_user_name":null,"truncated":false,"videoInfos":null,"musicInfos":null},"following":true,"blocking":false,"followed_by":false,"name":"连岳","location":",","id":"2264175753142745453","description":"","email":"*****@*****.**","gender":"1","verified":false,"url":"","screen_name":"lianyue","profile_image_url":"http://oimagea6.ydstatic.com/image?w=48&h=48&url=http%3A%2F%2F126.fm%2F3k99W4","created_at":"Tue Mar 30 12:13:35 +0800 2010","darenRec":"情感专家,著名专栏作家","favourites_count":"1","followers_count":"1006455","friends_count":"81","geo_enable":false,"icorp":"0","realName":null,"statuses_count":"2527","sysTag":["专栏作家","思想","情感"],"userTag":null,"in_groups":[]},
            //{"status":{"id":"7703093847719120921","source":"网易微博","text":"","created_at":"Fri Dec 09 11:27:01 +0800 2011","in_reply_to_screen_name":"lianyue","in_reply_to_status_id":"-423057201922397552","in_reply_to_user_id":"2264175753142745453","in_reply_to_user_name":"连岳","truncated":false,"videoInfos":null,"musicInfos":null},"following":true,"blocking":false,"followed_by":false,"name":"郑旭光","location":"北京市,昌平区","id":"-5757539258355407223","description":"","email":"*****@*****.**","gender":"1","verified":false,"url":"","screen_name":"zhengxuguang","profile_image_url":"http://oimagea3.ydstatic.com/image?w=48&h=48&url=http%3A%2F%2F126.fm%2F3TZTVb","created_at":"Tue Sep 28 15:41:53 +0800 2010","darenRec":"经济学达人","favourites_count":"1","followers_count":"1197810","friends_count":"993","geo_enable":false,"icorp":"0","realName":"心证自由","statuses_count":"15898","sysTag":["财经专栏"],"userTag":["政治经济学","哈耶克","米塞斯","司马迁","经济学","亚当斯密","门格尔","奥地利学派","杨朱"],"in_groups":[]}]
            return(list);
        }
예제 #9
0
        /// <summary>
        /// 同步消息
        /// </summary>
        /// <param name="accessToken">Access Token</param>
        /// <param name="accessSecret">Access Secret</param>
        /// <param name="text">消息</param>
        public void SendText(string accessToken, string accessSecret, string text)
        {
            List <UrlParameter> param = new List <UrlParameter>();

            param.Add(new UrlParameter("oauth_consumer_key", config.AppKey));
            param.Add(new UrlParameter("oauth_nonce", OAuthCommon.GetGUID32()));
            param.Add(new UrlParameter("oauth_signature_method", "HMAC-SHA1"));
            param.Add(new UrlParameter("oauth_timestamp", OAuthCommon.GetTimestamp()));
            param.Add(new UrlParameter("oauth_token", accessToken));
            param.Add(new UrlParameter("oauth_version", "1.0"));
            param.Add(new UrlParameter("status", text.SubString(270, "").UrlUpperEncode()));
            param.Sort(new UrlParameterCompre());

            StringBuilder sbSign = new StringBuilder().Append("POST&")
                                   .Append(Rfc3986.Encode(add))
                                   .Append("&")
                                   .Append(Rfc3986.Encode(OAuthCommon.GetUrlParameter(param)));

            param.Add(new UrlParameter("oauth_signature", Rfc3986.Encode(OAuthCommon.GetHMACSHA1(Rfc3986.Encode(config.AppSecret), Rfc3986.Encode(accessSecret), sbSign.ToString()))));
            param.Sort(new UrlParameterCompre());
            HttpHelper.SendPost(add, OAuthCommon.GetUrlParameter(param), "application/x-www-form-urlencoded");
        }
예제 #10
0
        /// <summary>
        /// 取登录账号信息
        /// </summary>
        /// <returns>取登录账号信息</returns>
        public UserInfo GetUserInfo()
        {
            UserInfo user    = new UserInfo();
            string   openid  = Request2.GetQ("openid");
            string   openkey = Request2.GetQ("openkey");

            List <UrlParameter> param = new List <UrlParameter>();

            param.Add(new UrlParameter("oauth_consumer_key", config.AppKey));
            param.Add(new UrlParameter("oauth_nonce", OAuthCommon.GetGUID32()));
            param.Add(new UrlParameter("oauth_signature_method", "HMAC-SHA1"));
            param.Add(new UrlParameter("oauth_timestamp", OAuthCommon.GetTimestamp()));
            param.Add(new UrlParameter("oauth_token", Request2.GetQ("oauth_token")));
            param.Add(new UrlParameter("oauth_verifier", Request2.GetQ("oauth_verifier")));
            param.Add(new UrlParameter("oauth_version", "1.0"));
            param.Sort(new UrlParameterCompre());

            StringBuilder sbSign = new StringBuilder().Append("GET&")
                                   .Append(access_token.UrlEncode2())
                                   .Append("&")
                                   .Append(OAuthCommon.GetUrlParameter(param).UrlEncode2());

            param.Add(new UrlParameter("oauth_signature", OAuthCommon.GetHMACSHA1(config.AppSecret, Session2.Get("oauth_token_secret"), sbSign.ToString()).UrlEncode2()));
            param.Sort(new UrlParameterCompre());
            string data = HttpHelper.SendGet(new StringBuilder().Append(access_token).Append("?").Append(OAuthCommon.GetUrlParameter(param)).ToString());

            int intOTS  = data.IndexOf("oauth_token=");
            int intOTSS = data.IndexOf("&oauth_token_secret=");
            int intUser = data.IndexOf("&user_id=");

            user.Token  = data.Substring(intOTS + 12, intOTSS - (intOTS + 12));
            user.Secret = data.Substring((intOTSS + 20), intUser - (intOTSS + 20));
            user.UserID = data.Substring((intUser + 9), data.Length - (intUser + 9));

            param.Clear();
            param.Add(new UrlParameter("oauth_consumer_key", config.AppKey));
            param.Add(new UrlParameter("oauth_nonce", OAuthCommon.GetGUID32()));
            param.Add(new UrlParameter("oauth_signature_method", "HMAC-SHA1"));
            param.Add(new UrlParameter("oauth_timestamp", OAuthCommon.GetTimestamp()));
            param.Add(new UrlParameter("oauth_token", user.Token));
            param.Add(new UrlParameter("oauth_version", "1.0"));
            param.Sort(new UrlParameterCompre());

            StringBuilder sbSign2 = new StringBuilder().Append("GET&")
                                    .Append(user_info.UrlEncode2())
                                    .Append("&")
                                    .Append(OAuthCommon.GetUrlParameter(param).UrlEncode2());

            param.Add(new UrlParameter("oauth_signature", OAuthCommon.GetHMACSHA1(config.AppSecret, user.Secret, sbSign2.ToString()).UrlEncode2()));
            param.Sort(new UrlParameterCompre());
            data = HttpHelper.SendGet(new StringBuilder().Append(user_info).Append("?").Append(OAuthCommon.GetUrlParameter(param)).ToString());

            user.Name    = data.GetMatchingValues("<name>(.+?)</name>", "<name>", "</name>").FirstOrDefault() ?? "";
            user.Header  = data.GetMatchingValues("<profile_image_url>(.+?)</profile_image_url>", "<profile_image_url>", "</profile_image_url>").FirstOrDefault() ?? "";
            user.Sex     = (data.GetMatchingValues("<gender>(.+?)</gender>", "<gender>", "</gender>").FirstOrDefault() ?? "").ToLower().Equals("m") ? 1 : 0;
            user.Address = data.GetMatchingValues("<location>(.+?)</location>", "<location>", "</location>").FirstOrDefault() ?? "";

            //Msg.Write(GetFriendsInfo(user.Token, user.Secret).ToJson());
            //SendText(user.Token, user.Secret, "测试数据2");
            return(user);
        }
예제 #11
0
        /// <summary>
        /// 取登录账号好友信息
        /// </summary>
        /// <param name="accessToken">Access Token</param>
        /// <param name="accessSecret">Access Secret</param>
        /// <returns>取登录账号好友信息</returns>
        public IList <UserInfo> GetFriendsInfo(string accessToken, string accessSecret)
        {
            IList <UserInfo> list = new List <UserInfo>();
            bool             isTrue = true; int count = 10; int page = 1;

            while (isTrue)
            {
                List <UrlParameter> param = new List <UrlParameter>();
                param.Add(new UrlParameter("oauth_consumer_key", config.AppKey));
                param.Add(new UrlParameter("oauth_nonce", OAuthCommon.GetGUID32()));
                param.Add(new UrlParameter("oauth_signature_method", "HMAC-SHA1"));
                param.Add(new UrlParameter("oauth_timestamp", OAuthCommon.GetTimestamp()));
                param.Add(new UrlParameter("oauth_token", accessToken));
                param.Add(new UrlParameter("oauth_version", "1.0"));
                param.Add(new UrlParameter("source", config.AppKey));
                param.Add(new UrlParameter("count", count));
                param.Add(new UrlParameter("cursor", count * (page - 1)));
                param.Sort(new UrlParameterCompre());

                StringBuilder sbSign = new StringBuilder().Append("GET&")
                                       .Append(friends_list.UrlEncode2())
                                       .Append("&")
                                       .Append(OAuthCommon.GetUrlParameter(param).UrlEncode2());

                param.Add(new UrlParameter("oauth_signature", OAuthCommon.GetHMACSHA1(config.AppSecret, accessSecret, sbSign.ToString()).UrlEncode2()));
                param.Sort(new UrlParameterCompre());
                string data = "";
                try {
                    data = HttpHelper.SendGet(new StringBuilder().Append(friends_list).Append("?").Append(OAuthCommon.GetUrlParameter(param)).ToString());
                    data = data.Substring(1, data.Length - 2);
                } catch {}
                IList <string> userlist = data.GetMatchingValues("{\"id\":(.+?)}}", "{", "}}");

                foreach (string info in userlist)
                {
                    UserInfo user = new UserInfo();
                    user.UserID  = info.GetMatchingValues("\"id\":(.+?),", "\"id\":", ",").FirstOrDefault() ?? "";
                    user.Email   = info.GetMatchingValues("\"email\":\"(.+?)\"", "\"email\":\"", "\"").FirstOrDefault() ?? "";
                    user.Name    = info.GetMatchingValues("\"name\":\"(.+?)\"", "\"name\":\"", "\"").FirstOrDefault() ?? "";
                    user.Sex     = (info.GetMatchingValues("\"gender\":\"(.+?)\"", "\"gender\":\"", "\"").FirstOrDefault() ?? "") == "m" ? 1 : 0;
                    user.Address = info.GetMatchingValues("\"location\":\"(.+?)\"", "\"location\":\"", "\"").FirstOrDefault() ?? "";
                    user.Header  = info.GetMatchingValues("\"profile_image_url\":\"(.+?)\"", "\"profile_image_url\":\"", "\"").FirstOrDefault() ?? "";
                    list.Add(user);
                }

                if (userlist.IsNull() || userlist.Count == 0)
                {
                    isTrue = false;
                }
                page++;
            }
            ;

            //{"users":[
            //{"id":1972885037,"screen_name":"","name":"","province":"11","city":"8","location":"","description":"","url":"","profile_image_url":"","domain":"diandianteam","gender":"m","followers_count":74327,"friends_count":69,"statuses_count":430,"favourites_count":1,"created_at":"Wed Feb 16 00:00:00 +0800 2011","following":false,"allow_all_act_msg":true,"geo_enabled":false,"verified":true,"remark":"","status":{"created_at":"Thu Dec 08 13:35:46 +0800 2011","id":3388322699728824,"text":"工场的兄弟产品,帮推哦[好得意]","source":"<a href=\"http://weibo.com\" rel=\"nofollow\">新浪微博</a>","favorited":false,"truncated":false,"in_reply_to_status_id":"","in_reply_to_user_id":"","in_reply_to_screen_name":"","geo":null,"mid":"3388322699728824","retweeted_status":{"created_at":"Wed Dec 07 15:46:22 +0800 2011","id":3387993178396122,"text":"当你想找iPhone/iTouch/iPad上的软件或游戏的时候,同步推就是一个:可以帮你找到所有好玩好用还想要软件的方便小帮手。现在登陆AppStore,可以直接下载同步推啦。iTunes下载地址:http://t.cn/SqiARV","source":"<a href=\"http://weibo.com\" rel=\"nofollow\">新浪微博</a>","favorited":false,"truncated":false,"in_reply_to_status_id":"","in_reply_to_user_id":"","in_reply_to_screen_name":"","thumbnail_pic":"http://ww2.sinaimg.cn/thumbnail/77dc26f5gw1dnu2qpro98j.jpg","bmiddle_pic":"http://ww2.sinaimg.cn/bmiddle/77dc26f5gw1dnu2qpro98j.jpg","original_pic":"http://ww2.sinaimg.cn/large/77dc26f5gw1dnu2qpro98j.jpg","geo":null,"mid":"3387993178396122","user":{"id":2010916597,"screen_name":"同步推","name":"同步推","province":"35","city":"2","location":"福建 厦门","description":"一站式浏览、下载、安装海量游戏和应用,超百万iPhone/iPad/iPod Touch 用户正在使用的免费应用商店。","url":"http://tui.tongbu.com","profile_image_url":"http://tp2.sinaimg.cn/2010916597/50/5617123876/0","domain":"tongbutui","gender":"f","followers_count":7341,"friends_count":39,"statuses_count":566,"favourites_count":3,"created_at":"Mon Mar 07 00:00:00 +0800 2011","following":false,"allow_all_act_msg":true,"geo_enabled":true,"verified":true}}}},
            //{"id":2493118952,"screen_name":"花瓣网","name":"花瓣网","province":"33","city":"1","location":"浙江 杭州","description":"花瓣网,帮你收集,发现网络上你喜欢的事物。 http://www.huaban.com/","url":"http://www.huaban.com/","profile_image_url":"http://tp1.sinaimg.cn/2493118952/50/5615173111/0","domain":"huabanwang","gender":"f","followers_count":14452,"friends_count":341,"statuses_count":287,"favourites_count":18,"created_at":"Tue Oct 25 00:00:00 +0800 2011","following":false,"allow_all_act_msg":true,"geo_enabled":true,"verified":true,"remark":"","status":{"created_at":"Fri Dec 09 09:26:55 +0800 2011","id":3388622462153735,"text":"来看这个趣味的采集:【可爱的垃圾袋】日本启动的一个GARBAGE BAG ART WORK(垃圾袋艺术品计划),由设计工作室MAQ主导,试图使得街头常见的垃圾袋变得更为美观,让城市风景更加美好。环保是全球的责任,就应该从最小的细节做起!http://t.cn/SqDsVw [撒花]","source":"<a href=\"http://weibo.com\" rel=\"nofollow\">新浪微博</a>","favorited":false,"truncated":false,"in_reply_to_status_id":"","in_reply_to_user_id":"","in_reply_to_screen_name":"","geo":null,"mid":"3388622462153735","retweeted_status":{"created_at":"Fri Dec 09 08:59:12 +0800 2011","id":3388615487373188,"text":"【可爱的垃圾袋】行走于日本的街头,如果看见这些漂亮的袋子,你肯定会好奇是谁忍心把这些有趣的袋子随意丢在街头呢?其实这是日本启动的一个GARBAGE BAG ART WORK(垃圾袋艺术品计划),由设计工作室MAQ主导,试图... http://t.cn/SqDsVw  (分享自 @花瓣网)","source":"<a href=\"http://huaban.com/\" rel=\"nofollow\">花瓣网</a>","favorited":false,"truncated":false,"in_reply_to_status_id":"","in_reply_to_user_id":"","in_reply_to_screen_name":"","thumbnail_pic":"http://ww3.sinaimg.cn/thumbnail/67f7a5a4jw1dnw282j5mej.jpg","bmiddle_pic":"http://ww3.sinaimg.cn/bmiddle/67f7a5a4jw1dnw282j5mej.jpg","original_pic":"http://ww3.sinaimg.cn/large/67f7a5a4jw1dnw282j5mej.jpg","geo":null,"mid":"3388615487373188","user":{"id":1744283044,"screen_name":"杭州小杰","name":"杭州小杰","province":"33","city":"1","location":"浙江 杭州","description":"眼泪眼屎,意守丹田。","url":"","profile_image_url":"http://tp1.sinaimg.cn/1744283044/50/1289142138/1","domain":"jf882736","gender":"m","followers_count":758,"friends_count":228,"statuses_count":1173,"favourites_count":11,"created_at":"Thu May 20 00:00:00 +0800 2010","following":false,"allow_all_act_msg":false,"geo_enabled":true,"verified":false}}}},
            //{"id":1662047260,"screen_name":"SinaAppEngine","name":"SinaAppEngine","province":"11","city":"8","location":"北京 海淀区","description":"Sina App Engine专注于提供高品质的应用云服务.您可以访问我们的网站了解更多信息 http://sae.sina.com.cn","url":"http://sae.sina.com.cn","profile_image_url":"http://tp1.sinaimg.cn/1662047260/50/1258613353/1","domain":"saet","gender":"m","followers_count":111018,"friends_count":114,"statuses_count":1867,"favourites_count":15,"created_at":"Thu Nov 19 00:00:00 +0800 2009","following":false,"allow_all_act_msg":true,"geo_enabled":true,"verified":true,"remark":"","status":{"created_at":"Fri Dec 09 10:02:38 +0800 2011","id":3388631445927062,"text":"恭喜,#线上活动#真欢乐!","source":"<a href=\"http://event.weibo.com/\" rel=\"nofollow\">微活动</a>","favorited":false,"truncated":false,"in_reply_to_status_id":"","in_reply_to_user_id":"","in_reply_to_screen_name":"","geo":null,"mid":"3388631445927062","retweeted_status":{"created_at":"Thu Dec 08 16:25:46 +0800 2011","id":3388365481554324,"text":"O(∩_∩)O#线上活动#奔放上线!http://t.cn/Squlm0这哥们木有#有奖活动#一掷千金滴气派,也缺乏#同城活动#惊艳遇见滴可能,But!TA有颗迷恋新鲜滴心,TA热衷创意、流连灵感…TA具有#普通 文艺 2X青年#多重气质,令人感叹#看到它我就XX了#。TA!就是微活动家滴活宝,等你调戏http://t.cn/Sqn9hQ","source":"<a href=\"http://event.weibo.com/\" rel=\"nofollow\">微活动</a>","favorited":false,"truncated":false,"in_reply_to_status_id":"","in_reply_to_user_id":"","in_reply_to_screen_name":"","thumbnail_pic":"http://ww4.sinaimg.cn/thumbnail/6f20c747tw1dnv9826m22j.jpg","bmiddle_pic":"http://ww4.sinaimg.cn/bmiddle/6f20c747tw1dnv9826m22j.jpg","original_pic":"http://ww4.sinaimg.cn/large/6f20c747tw1dnv9826m22j.jpg","geo":null,"mid":"3388365481554324","user":{"id":1864419143,"screen_name":"活动小队长","name":"活动小队长","province":"11","city":"8","location":"北京 海淀区","description":"新浪微博微活动平台官方微博。 靠谱活动推荐 惊喜你的生活!    <br />\n周一至周五 9:30-18:30 为您答疑解惑!<br />\n         <br />\n活动合作\\…","url":"http://event.weibo.com","profile_image_url":"http://tp4.sinaimg.cn/1864419143/50/5601946761/0","domain":"event","gender":"f","followers_count":877553,"friends_count":394,"statuses_count":2439,"favourites_count":8,"created_at":"Tue Nov 16 00:00:00 +0800 2010","following":false,"allow_all_act_msg":true,"geo_enabled":true,"verified":true},"annotations":[{"source":{"id":"294315","appid":"38","name":"#线上活动#欢乐上线!转发赢限量奖品","title":"#线上活动#欢乐上...","url":"http://event.weibo.com/294315"}}]}}},
            //{"id":1579058951,"screen_name":"课件培训-何佳瑾","name":"课件培训-何佳瑾","province":"11","city":"2","location":"北京 西城区","description":"不懂美工和IT,做出一流水准的专业高效PPT与快速课件。","url":"http://blog.sina.com.cn/kejianttt","profile_image_url":"http://tp4.sinaimg.cn/1579058951/50/5609489542/0","domain":"kejianttt","gender":"f","followers_count":1081,"friends_count":318,"statuses_count":206,"favourites_count":26,"created_at":"Sat Nov 07 00:00:00 +0800 2009","following":false,"allow_all_act_msg":true,"geo_enabled":false,"verified":false,"remark":"","status":{"created_at":"Fri Dec 09 08:53:52 +0800 2011","id":3388614145058479,"text":"#JJ学习#提升课程有效性的关键之四:课程是否让学员展示了理解程度? 评估学员对课程内容的理解程度,将有助于学员将所学内容与已有知识整合起来。选择题或判断题只能显示一个人是否知道了某项事实。要衡量学员对所学知识的理解程度,应当是看他是否能把这些事实运用于决策。(何佳瑾整编自Articulate)","source":"<a href=\"http://weibo.com\" rel=\"nofollow\">新浪微博</a>","favorited":false,"truncated":false,"in_reply_to_status_id":"","in_reply_to_user_id":"","in_reply_to_screen_name":"","geo":null,"mid":"3388614145058479"}},{"id":1175961930,"screen_name":"俞小白童鞋","name":"俞小白童鞋","province":"31","city":"15","location":"上海 浦东新区","description":"曾经有一人,爱我如生命。","url":"http://blog.sina.com.cn/yamamototaro","profile_image_url":"http://tp3.sinaimg.cn/1175961930/50/5607261690/1","domain":"yamamototaro","gender":"m","followers_count":879,"friends_count":182,"statuses_count":6460,"favourites_count":109,"created_at":"Wed Mar 31 00:00:00 +0800 2010","following":false,"allow_all_act_msg":false,"geo_enabled":true,"verified":false,"remark":"","status":{"created_at":"Thu Dec 08 22:13:17 +0800 2011","id":3388452935175529,"text":"转发微博。","source":"<a href=\"http://weibo.com/mobile/iphone.php\" rel=\"nofollow\">iPhone客户端</a>","favorited":false,"truncated":false,"in_reply_to_status_id":"","in_reply_to_user_id":"","in_reply_to_screen_name":"","geo":null,"mid":"3388452935175529","retweeted_status":{"created_at":"Thu Dec 08 21:43:10 +0800 2011","id":3388445355582747,"text":"有的恋爱像吃大的蛋糕,你要切下几刀后,才能开始嚐到它的甜。有的恋爱像吃小的蛋糕,才吃一口,就吃完了。有的恋爱像吃甜甜圈,你一边嚐到它的甜,一边清楚的看见:它的心是空的。。。。【 康永 - 给未知恋人的爱情短信 】...........................( 图 * 郑维 作品 )","source":"<a href=\"http://weibo.com/mobile/iphone.php\" rel=\"nofollow\">iPhone客户端</a>","favorited":false,"truncated":false,"in_reply_to_status_id":"","in_reply_to_user_id":"","in_reply_to_screen_name":"","thumbnail_pic":"http://ww1.sinaimg.cn/thumbnail/4c69db7djw1dnvionwxohj.jpg","bmiddle_pic":"http://ww1.sinaimg.cn/bmiddle/4c69db7djw1dnvionwxohj.jpg","original_pic":"http://ww1.sinaimg.cn/large/4c69db7djw1dnvionwxohj.jpg","geo":null,"mid":"3388445355582747","user":{"id":1282005885,"screen_name":"蔡康永","name":"蔡康永","province":"71","city":"1000","location":"台湾","description":"** 工作邀約康永, 請洽經紀公司: [email protected] // ( 北京傳真FAX )+86-10-65309417 // ( 台北傳真FAX )+886-2-27523638","url":"http://blog.sina.com.cn/caikangyong","profile_image_url":"http://tp2.sinaimg.cn/1282005885/50/5617303476/1","domain":"caikangyong","gender":"m","followers_count":12115806,"friends_count":413,"statuses_count":489,"favourites_count":1577,"created_at":"Fri Aug 28 00:00:00 +0800 2009","following":false,"allow_all_act_msg":false,"geo_enabled":true,"verified":true},"annotations":[{"server_ip":"10.73.19.66"}]},"annotations":[]}},
            //{"id":1712092715,"screen_name":"eLearning实施","name":"eLearning实施","province":"31","city":"1000","location":"上海","description":"热爱e-Learning,关注e-Learning现状和发展趋势,专注于企业e-Learning实施。","url":"","profile_image_url":"http://tp4.sinaimg.cn/1712092715/50/1300094129/0","domain":"sumanelearning","gender":"f","followers_count":538,"friends_count":173,"statuses_count":73,"favourites_count":11,"created_at":"Wed Mar 31 00:00:00 +0800 2010","following":false,"allow_all_act_msg":false,"geo_enabled":true,"verified":false,"remark":"","status":{"created_at":"Sat Aug 13 17:49:25 +0800 2011","id":3345987150202697,"text":"每个人在不同的场合,都要扮演不同的角色,不分场合或混淆觉色都是不负责的。“活在当下”,在当下全情投入,演好我的角色。","source":"<a href=\"http://weibo.com/mobile/wap.php\" rel=\"nofollow\">新浪微博手机版</a>","favorited":false,"truncated":false,"in_reply_to_status_id":"","in_reply_to_user_id":"","in_reply_to_screen_name":"","geo":null,"mid":"3345987150202697","retweeted_status":{"created_at":"Sat Aug 13 16:41:33 +0800 2011","id":3345970070820733,"text":"上一分钟在咖啡馆接受记者的采访,大谈特谈网络文学和影视改编,下一分钟采访结束告别记者立马奔进超市,化身打算买菜回家做饭的欧巴桑。[害羞]","source":"<a href=\"http://weibo.com/mobile/iphone.php\" rel=\"nofollow\">iPhone客户端</a>","favorited":false,"truncated":false,"in_reply_to_status_id":"","in_reply_to_user_id":"","in_reply_to_screen_name":"","geo":null,"mid":"3345970070820733","user":{"id":1225419417,"screen_name":"匪我思存","name":"匪我思存","province":"42","city":"1","location":"湖北 武汉","description":"人懒、嘴馋、会拖稿、间歇刷屏、话痨、假装有文化、品味差。不看@,有事请写信:[email protected]","url":"http://www.feiwosicun.net/bbs/index.php","profile_image_url":"http://tp2.sinaimg.cn/1225419417/50/1279875696/0","domain":"fwsc","gender":"f","followers_count":388309,"friends_count":163,"statuses_count":3350,"favourites_count":6,"created_at":"Fri Aug 28 00:00:00 +0800 2009","following":false,"allow_all_act_msg":false,"geo_enabled":false,"verified":true},"annotations":[{"server_ip":"10.73.19.140"}]},"annotations":[]}},
            //{"id":2030979823,"screen_name":"林海lloyd","name":"林海lloyd","province":"31","city":"1000","location":"上海","description":"","url":"","profile_image_url":"http://tp4.sinaimg.cn/2030979823/50/5602042778/1","domain":"","gender":"m","followers_count":47,"friends_count":39,"statuses_count":21,"favourites_count":11,"created_at":"Thu Mar 17 00:00:00 +0800 2011","following":false,"allow_all_act_msg":false,"geo_enabled":true,"verified":false,"remark":"","status":{"created_at":"Tue Nov 29 12:00:29 +0800 2011","id":3385037228465654,"text":"這事怎麼會髮生,30顆螺絲啊,要死人的!!![怒骂][怒骂][怒骂]","source":"<a href=\"http://weibo.com/mobile/android.php\" rel=\"nofollow\">Android客户端</a>","favorited":false,"truncated":false,"in_reply_to_status_id":"","in_reply_to_user_id":"","in_reply_to_screen_name":"","geo":null,"mid":"3385037228465654","retweeted_status":{"created_at":"Tue Nov 29 10:30:11 +0800 2011","id":3385014504838578,"text":"【法国航空公司客机在中国维修后发现少30颗螺钉】太让人虚惊了,法国航空公司一架空客A340客机在中国厦门维修后,继续飞行,几天後才发现飞机的一块保护板上竟然少了近30个螺丝钉。继“中国制造”之后,“中国维修”也要威震世界了!http://t.cn/SUrBIn","source":"<a href=\"http://weibo.com\" rel=\"nofollow\">新浪微博</a>","favorited":false,"truncated":false,"in_reply_to_status_id":"","in_reply_to_user_id":"","in_reply_to_screen_name":"","thumbnail_pic":"http://ww4.sinaimg.cn/thumbnail/71ced708tw1dnkknmmmxfj.jpg","bmiddle_pic":"http://ww4.sinaimg.cn/bmiddle/71ced708tw1dnkknmmmxfj.jpg","original_pic":"http://ww4.sinaimg.cn/large/71ced708tw1dnkknmmmxfj.jpg","geo":null,"mid":"3385014504838578","user":{"id":1909380872,"screen_name":"企业家智库","name":"企业家智库","province":"11","city":"1000","location":"北京","description":"微博中最具影响力的商界精英聚集地!欢迎关注分享。","url":"http://weibo.com/jingcaimingren","profile_image_url":"http://tp1.sinaimg.cn/1909380872/50/5617266792/1","domain":"nannvqushi","gender":"m","followers_count":184194,"friends_count":378,"statuses_count":5545,"favourites_count":1591,"created_at":"Mon Dec 27 00:00:00 +0800 2010","following":false,"allow_all_act_msg":true,"geo_enabled":true,"verified":false}},"annotations":[]}},
            //{"id":1842500341,"screen_name":"病态的栗子","name":"病态的栗子","province":"31","city":"1000","location":"上海","description":"呐喊——以拒绝同流合污的名义!","url":"","profile_image_url":"http://tp2.sinaimg.cn/1842500341/50/5615791638/1","domain":"","gender":"m","followers_count":98,"friends_count":74,"statuses_count":541,"favourites_count":2,"created_at":"Sat Oct 30 00:00:00 +0800 2010","following":false,"allow_all_act_msg":false,"geo_enabled":true,"verified":false,"remark":"","status":{"created_at":"Thu Dec 08 09:18:24 +0800 2011","id":3388257929528921,"text":"中国哲学的根基其实是思辩,有很强的逻辑,并非只重效而忽略理,恰恰相反。重效而略理往往欲速不达,好效一定有逻辑,不能因为你看不透而认为不重要,这是本末倒置。培训人做坏了培训业。 //@丶陈大钢:// @赵克欣 : 道,无形无相,如糖入水,视之不见,尝之有味。","source":"<a href=\"http://weibo.com/mobile/iphone.php\" rel=\"nofollow\">iPhone客户端</a>","favorited":false,"truncated":false,"in_reply_to_status_id":"","in_reply_to_user_id":"","in_reply_to_screen_name":"","geo":null,"mid":"3388257929528921","retweeted_status":{"created_at":"Wed Dec 07 23:42:57 +0800 2011","id":3388113113705520,"text":"行动学习催化师需要对企业文化有充分的认识与理解,否则会陷到机械的流程与技术中,忘记学习本身就是适变过程。在系统和谐前提下,有效比有道理更重要。","source":"<a href=\"http://weibo.com/mobile/ipad.php\" rel=\"nofollow\">iPad客户端</a>","favorited":false,"truncated":false,"in_reply_to_status_id":"","in_reply_to_user_id":"","in_reply_to_screen_name":"","geo":null,"mid":"3388113113705520","user":{"id":1738470153,"screen_name":"李珂nichole","name":"李珂nichole","province":"44","city":"3","location":"广东 深圳","description":"管理培训 培训师培训 培训系统","url":"http://blog.sina.com.cn/u/1738470153","profile_image_url":"http://tp2.sinaimg.cn/1738470153/50/5616159177/0","domain":"sznichole","gender":"f","followers_count":906,"friends_count":337,"statuses_count":1280,"favourites_count":123,"created_at":"Tue Jul 13 00:00:00 +0800 2010","following":false,"allow_all_act_msg":false,"geo_enabled":true,"verified":false}},"annotations":[]}},
            //{"id":1890959170,"screen_name":"江姜蒋","name":"江姜蒋","province":"31","city":"1000","location":"上海","description":"","url":"","profile_image_url":"http://tp3.sinaimg.cn/1890959170/50/5613749110/0","domain":"yvonne001","gender":"f","followers_count":90,"friends_count":98,"statuses_count":712,"favourites_count":26,"created_at":"Thu Dec 09 00:00:00 +0800 2010","following":false,"allow_all_act_msg":false,"geo_enabled":true,"verified":false,"remark":"","status":{"created_at":"Thu Dec 08 17:50:54 +0800 2011","id":3388386905931032,"text":"//@俞小白童鞋: @壹嗰餃釨","source":"<a href=\"http://weibo.com\" rel=\"nofollow\">新浪微博</a>","favorited":false,"truncated":false,"in_reply_to_status_id":"","in_reply_to_user_id":"","in_reply_to_screen_name":"","geo":null,"mid":"3388386905931032","retweeted_status":{"created_at":"Mon Nov 28 15:35:05 +0800 2011","id":3384728843254125,"text":"#YouTube闪闪亮#【坠机可怕,更可怕的是。。。】如此淡定的机长![生病] 还有如此配合的空姐。。。![闪电] http://t.cn/S4GtnR 你们淡定,我们蛋疼呀!![抓狂]","source":"<a href=\"http://weibo.com\" rel=\"nofollow\">新浪微博</a>","favorited":false,"truncated":false,"in_reply_to_status_id":"","in_reply_to_user_id":"","in_reply_to_screen_name":"","thumbnail_pic":"http://ww3.sinaimg.cn/thumbnail/83fae389tw1dnjntnk65kj.jpg","bmiddle_pic":"http://ww3.sinaimg.cn/bmiddle/83fae389tw1dnjntnk65kj.jpg","original_pic":"http://ww3.sinaimg.cn/large/83fae389tw1dnjntnk65kj.jpg","geo":null,"mid":"3384728843254125","user":{"id":2214257545,"screen_name":"YouTube精选","name":"YouTube精选","province":"400","city":"1","location":"海外 美国","description":"国内要刷微博,国外也要刷微博,作为一个搬运工,最重要的是不怕河蟹,墙内墙外都是浮云,我是YouTube精选,我在weibo.com","url":"http://weibo.com/youtube","profile_image_url":"http://tp2.sinaimg.cn/2214257545/50/5604558022/0","domain":"youtube","gender":"f","followers_count":326225,"friends_count":327,"statuses_count":2312,"favourites_count":9,"created_at":"Sat Jul 02 00:00:00 +0800 2011","following":false,"allow_all_act_msg":true,"geo_enabled":true,"verified":false}}}},
            //{"id":1688983163,"screen_name":"keylogic王成","name":"keylogic王成","province":"11","city":"1","location":"北京 东城区","description":"KeyLogic公司创始人,秉承“赋能于人”的使命和“专业主义”的价值观创业,爱人才、喜战略、奉儒释道、求民主自由","url":"","profile_image_url":"http://tp4.sinaimg.cn/1688983163/50/5617696588/1","domain":"wangchengkeylogic","gender":"m","followers_count":1714,"friends_count":458,"statuses_count":969,"favourites_count":1,"created_at":"Tue Feb 02 00:00:00 +0800 2010","following":false,"allow_all_act_msg":false,"geo_enabled":true,"verified":false,"remark":"","status":{"created_at":"Thu Dec 08 23:45:38 +0800 2011","id":3388476173068478,"text":"越是乱时越需要静,静时方能心清:)","source":"<a href=\"http://weibo.com\" rel=\"nofollow\">新浪微博</a>","favorited":false,"truncated":false,"in_reply_to_status_id":"","in_reply_to_user_id":"","in_reply_to_screen_name":"","geo":null,"mid":"3388476173068478","retweeted_status":{"created_at":"Thu Dec 08 23:44:22 +0800 2011","id":3388475858817826,"text":"悟:人在忙时最容易出现心乱,心乱则事更乱。回顾师父 @济群法师 昨天晚霞的微博,让我体验到心静则国土净。越是乱时越需要静,静时方能心清。同时困难时候往往是提升的最佳时机与机遇。回到公司,静、定、思一下,心清净许多。过程全力以赴,果上随缘,无怨无悔!","source":"<a href=\"http://weibo.com\" rel=\"nofollow\">新浪微博</a>","favorited":false,"truncated":false,"in_reply_to_status_id":"","in_reply_to_user_id":"","in_reply_to_screen_name":"","thumbnail_pic":"http://ww3.sinaimg.cn/thumbnail/68583a48gw1dnvm4bzfd3j.jpg","bmiddle_pic":"http://ww3.sinaimg.cn/bmiddle/68583a48gw1dnvm4bzfd3j.jpg","original_pic":"http://ww3.sinaimg.cn/large/68583a48gw1dnvm4bzfd3j.jpg","geo":null,"mid":"3388475858817826","user":{"id":1750612552,"screen_name":"菩提禅缘","name":"菩提禅缘","province":"33","city":"1","location":"浙江 杭州","description":"皈依 @济群法师 门下,于菩提书院修学道次第!随缘无我,如梦如幻!菩提大道,三学增上!阿里十年、风雨同舟!----淘宝禅缘 (陈瑜、觉贤居士)","url":"http://blog.sina.com.cn/putichanyuan","profile_image_url":"http://tp1.sinaimg.cn/1750612552/50/1279901586/1","domain":"putichanyuan","gender":"m","followers_count":11522,"friends_count":473,"statuses_count":1331,"favourites_count":30,"created_at":"Fri Jun 04 00:00:00 +0800 2010","following":false,"allow_all_act_msg":true,"geo_enabled":false,"verified":true}}}}
            //],"next_cursor":10,"previous_cursor":0}
            return(list);
        }
예제 #12
0
        /// <summary>
        /// 取登录账号好友信息
        /// </summary>
        /// <param name="accessToken">Access Token</param>
        /// <param name="accessSecret">Access Secret</param>
        /// <returns>取登录账号好友信息</returns>
        public IList <UserInfo> GetFriendsInfo(string accessToken, string accessSecret)
        {
            IList <UserInfo> list = new List <UserInfo>();
            bool             isTrue = true; int count = 10; int page = 1;

            while (isTrue)
            {
                List <UrlParameter> param = new List <UrlParameter>();
                param.Add(new UrlParameter("oauth_consumer_key", config.AppKey));
                param.Add(new UrlParameter("oauth_nonce", OAuthCommon.GetGUID32()));
                param.Add(new UrlParameter("oauth_signature_method", "HMAC-SHA1"));
                param.Add(new UrlParameter("oauth_timestamp", OAuthCommon.GetTimestamp()));
                param.Add(new UrlParameter("oauth_token", accessToken));
                param.Add(new UrlParameter("oauth_version", "1.0"));
                param.Add(new UrlParameter("format", "json"));
                param.Add(new UrlParameter("reqnum", count));
                param.Add(new UrlParameter("startindex", count * (page - 1)));
                param.Sort(new UrlParameterCompre());

                StringBuilder sbSign = new StringBuilder().Append("GET&")
                                       .Append(friends_list.UrlEncode2())
                                       .Append("&")
                                       .Append(OAuthCommon.GetUrlParameter(param).UrlEncode2());

                param.Add(new UrlParameter("oauth_signature", OAuthCommon.GetHMACSHA1(config.AppSecret, accessSecret, sbSign.ToString()).UrlEncode2()));
                param.Sort(new UrlParameterCompre());
                string         data     = HttpHelper.SendGet(new StringBuilder().Append(friends_list).Append("?").Append(OAuthCommon.GetUrlParameter(param)).ToString());
                IList <string> userlist = data.GetMatchingValues("{\"city_code\"(.+?)}]}", "{\"city_code\"", "}]}");

                foreach (string info in userlist)
                {
                    UserInfo user = new UserInfo();
                    user.UserID  = info.GetMatchingValues("\"name\":\"(.+?)\"", "\"name\":\"", "\"").FirstOrDefault() ?? "";
                    user.Email   = info.GetMatchingValues("\"email\":\"(.+?)\"", "\"email\":\"", "\"").FirstOrDefault() ?? "";
                    user.Name    = info.GetMatchingValues("\"nick\":\"(.+?)\"", "\"nick\":\"", "\"").FirstOrDefault() ?? "";
                    user.Sex     = (info.GetMatchingValues("\"sex\":(.+?),", "\"sex\":", ",").FirstOrDefault() ?? "") == "1" ? 1 : 0;
                    user.Address = info.GetMatchingValues("\"location\":\"(.+?)\"", "\"location\":\"", "\"").FirstOrDefault() ?? "";
                    user.Header  = info.GetMatchingValues("\"head\":\"(.+?)\"", "\"head\":\"", "\"").FirstOrDefault() ?? "";
                    list.Add(user);
                }

                if (userlist.IsNull() || userlist.Count == 0)
                {
                    isTrue = false;
                }
                page++;
            }
            ;

            //{"data":{"hasnext":0,"info":[
            //{"city_code":"1","country_code":"1","fansnum":1517049,"head":"http://app.qlogo.cn/mbloghead/a234df2a8474d1e853be","idolnum":25,"isidol":true,"isvip":1,"location":"未知","name":"tncmayun","nick":"TNC马云","openid":"","province_code":"33","tag":null,"tweet":[{"from":"腾讯微博","id":"18650095129418","text":"看着家人的眼泪,听见同事们疲惫委屈的声音,心悴了,真累了,真想放弃。心里无数次责问自己:我们为了什么?凭啥去承担如此的责任?也许商人赚了钱就该过舒适生活,或象别人一样移民,社会好坏和我们有啥关系?昨晚上网听见那批人高奏纳粹军歌,呼喊"消灭一切,摧毁一切"伤害着无辜。亲,淘宝人!!","timestamp":1318479818}]},
            //{"city_code":"","country_code":"1","fansnum":100,"head":"http://app.qlogo.cn/mbloghead/51d6d26e67012a6e069c","idolnum":136,"isidol":true,"isvip":0,"location":"未知","name":"pandorcai","nick":"蔡日","openid":"","province_code":"31","tag":[{"id":"77846971042806542","name":"旅游"},{"id":"595526330566555944","name":"逛论坛"},{"id":"3116172981967911833","name":"爱睡觉"},{"id":"3428083006598920604","name":"上网"},{"id":"4762518206506141882","name":"游戏"},{"id":"7632343735443733612","name":"听音乐"},{"id":"8143061372111998179","name":"看书"},{"id":"9393533470027694381","name":"看电影"},{"id":"12117796803083473608","name":"美食"},{"id":"16511128160049158514","name":"程序员"}],"tweet":[{"from":"QQ签名","id":"71615048757565","text":"两个月六张罚单的人伤不起呀","timestamp":1322884522}]},
            //{"city_code":"","country_code":"1","fansnum":69,"head":"http://app.qlogo.cn/mbloghead/a024e15a9310b3f5179c","idolnum":35,"isidol":true,"isvip":0,"location":"未知","name":"willyjl","nick":"杨洁丽","openid":"","province_code":"31","tag":null,"tweet":[{"from":"腾讯微博","id":"73020113642003","text":"凭我的姿色,竟然只需交这么点税收!‘地球形象税收局’的审美观真是令我不敢恭维。快来看看你要纳多少#形象税#:http://url.cn/3YFsGb ","timestamp":1310006202}]},
            //{"city_code":"","country_code":"1","fansnum":12,"head":"http://app.qlogo.cn/mbloghead/7d5c58b2cdd733963f32","idolnum":37,"isidol":true,"isvip":0,"location":"未知","name":"nina20101012","nick":"珠珠","openid":"","province_code":"31","tag":null,"tweet":[{"from":"腾讯微博","id":"78580001467265","text":"今天看新闻了,那个叫悦悦的小女孩儿太可怜了,几分钟被4个轮子压过去,本来可以避免那么严重的后果的,为什么路人都那么漠视,那是生命啊!,太气人了,鄙视你们,会有报应的","timestamp":1318943847}]},
            //{"city_code":"1","country_code":"1","fansnum":168,"head":"http://app.qlogo.cn/mbloghead/57875e17a4bce1fbb702","idolnum":284,"isidol":true,"isvip":0,"location":"未知","name":"killmyleon","nick":"乐乐","openid":"","province_code":"41","tag":[{"id":"3296752990863134558","name":"恋爱ING"},{"id":"3428083006598920604","name":"上网"},{"id":"8486326060299489387","name":"邪恶"},{"id":"9393533470027694381","name":"看电影"},{"id":"12093106934468067613","name":"ubuntu"},{"id":"13717765964038710262","name":"努力ING"},{"id":"14438978826104116590","name":"debian"},{"id":"14847358170114098914","name":"linux"},{"id":"16469568389185112236","name":"各种宅"}],"tweet":[{"from":"QQ签名","id":"52611047553060","text":"坚持就是胜利!","timestamp":1322091149}]},
            //{"city_code":"","country_code":"","fansnum":229,"head":"http://app.qlogo.cn/mbloghead/ad7b87d35771ebd0bcd0","idolnum":125,"isidol":true,"isvip":0,"location":"","name":"iamyanghua","nick":"杨华","openid":"","province_code":"","tag":[{"id":"77846971042806542","name":"旅游"},{"id":"4762518206506141882","name":"游戏"}],"tweet":[{"from":"","id":"0","text":"","timestamp":0}]},
            //{"city_code":"","country_code":"","fansnum":1253,"head":"http://app.qlogo.cn/mbloghead/21663a093b620c1150d8","idolnum":6,"isidol":true,"isvip":0,"location":"未知","name":"MEIZU_SH","nick":"魅族_上海","openid":"","province_code":"","tag":[{"id":"3314035123865995316","name":"魅族徐家汇旗舰店"},{"id":"4766081530055180763","name":"魅族上海"},{"id":"5840235084298680107","name":"魅族手机"},{"id":"9912118391828821150","name":"MEIZU"},{"id":"13082348043929536259","name":"魅族"},{"id":"13609997272425797546","name":"魅族专卖店"},{"id":"14986941257412550705","name":"M9"},{"id":"15053646515186054983","name":"魅族旗舰店"},{"id":"15236338144929393964","name":"上海心意"}],"tweet":[{"from":"腾讯微博","id":"19218047161270","text":"#MX最新消息#魅族MX试玩视频 http://url.cn/3MYnA4   大家一睹为快 http://url.cn/3yjgiY ","timestamp":1323313998}]},
            //{"city_code":"","country_code":"1","fansnum":3160,"head":"http://app.qlogo.cn/mbloghead/09694c818d98c2b440a6","idolnum":10,"isidol":true,"isvip":0,"location":"未知","name":"lovemeizu","nick":"魅族迷","openid":"","province_code":"31","tag":[{"id":"399381935516400475","name":"m9"},{"id":"1433216300070607690","name":"80后"},{"id":"7120965338382079114","name":"舌头可以舔到鼻子"},{"id":"12149833612181773251","name":"android"},{"id":"13082348043929536259","name":"魅族"},{"id":"14193650147949730220","name":"数码"},{"id":"14743408212463651736","name":"m8"},{"id":"17382413701540968475","name":"没生过病"}],"tweet":[{"from":"腾讯微博","id":"38016132218810","text":"魅族M9手机上市时可能会有每月赠送88元的186套餐供选择。合约机价格与裸机价一样,同为8GB版2499元、16GB版2699元。    这是 J.Wong 首次论及M9与联通合约套餐方案的信息,同时披露16GB版M9的价格为2699元。 但随后称目前套餐方案还未定,并提到,“如果有合作套餐的话届时可以直接在专卖店办理。”","timestamp":1290763523}]},
            //{"city_code":"","country_code":"1","fansnum":9362,"head":"http://app.qlogo.cn/mbloghead/32f1c38a5d2ef62b918e","idolnum":0,"isidol":true,"isvip":0,"location":"未知","name":"meizutech","nick":"魅族资讯","openid":"","province_code":"31","tag":[{"id":"77846971042806542","name":"旅游"},{"id":"595526330566555944","name":"逛论坛"},{"id":"797311093297244621","name":"爬山"},{"id":"3428083006598920604","name":"上网"},{"id":"7632343735443733612","name":"听音乐"},{"id":"9393533470027694381","name":"看电影"},{"id":"13082348043929536259","name":"魅族"},{"id":"14728618028410374988","name":"摄影"},{"id":"14986941257412550705","name":"M9"},{"id":"17168216440080056340","name":"爱狗"}],"tweet":[{"from":"腾讯微博","id":"71120012656231","text":"魅族的壁纸单张的版权费就几百美金,不知道商业授权要多少钱。肯定很吓人。","timestamp":1323324978}]},
            //{"city_code":"1","country_code":"1","fansnum":18,"head":"http://app.qlogo.cn/mbloghead/029e58a18b7fc410a238","idolnum":80,"isidol":true,"isvip":0,"location":"未知","name":"z580019","nick":"zxm","openid":"","province_code":"41","tag":null,"tweet":[{"from":"QQ空间说说","id":"220052593834","text":"[em]e300[/em]v","timestamp":1323041442}]}],
            //"timestamp":1323327658},"errcode":0,"msg":"ok","ret":0}
            return(list);
        }
예제 #13
0
        /// <summary>
        /// 取登录账号信息
        /// </summary>
        /// <returns>取登录账号信息</returns>
        public UserInfo GetUserInfo()
        {
            UserInfo user = new UserInfo();

            List <UrlParameter> param = new List <UrlParameter>();

            param.Add(new UrlParameter("oauth_consumer_key", config.AppKey));
            param.Add(new UrlParameter("oauth_nonce", OAuthCommon.GetGUID32()));
            param.Add(new UrlParameter("oauth_signature_method", "HMAC-SHA1"));
            param.Add(new UrlParameter("oauth_timestamp", OAuthCommon.GetTimestamp()));
            param.Add(new UrlParameter("oauth_token", Request2.GetQ("oauth_token")));
            param.Add(new UrlParameter("oauth_verifier", Request2.GetQ("oauth_verifier")));
            param.Add(new UrlParameter("oauth_version", "1.0"));
            param.Sort(new UrlParameterCompre());

            StringBuilder sbSign = new StringBuilder().Append("GET&")
                                   .Append(Rfc3986.Encode(access_token))
                                   .Append("&")
                                   .Append(Rfc3986.Encode(OAuthCommon.GetUrlParameter(param)));

            param.Add(new UrlParameter("oauth_signature", Rfc3986.Encode(OAuthCommon.GetHMACSHA1(Rfc3986.Encode(config.AppSecret), Rfc3986.Encode(Session2.Get("oauth_token_secret")), sbSign.ToString()))));
            param.Sort(new UrlParameterCompre());
            string data = HttpHelper.SendGet(new StringBuilder().Append(access_token).Append("?").Append(OAuthCommon.GetUrlParameter(param)).ToString()) + "&";

            user.Token  = data.GetMatchingValues("oauth_token=(.+?)&", "oauth_token=", "&").FirstOrDefault() ?? "";
            user.Secret = data.GetMatchingValues("oauth_token_secret=(.+?)&", "oauth_token_secret=", "&").FirstOrDefault() ?? "";

            param.Clear();
            param.Add(new UrlParameter("oauth_consumer_key", config.AppKey));
            param.Add(new UrlParameter("oauth_nonce", OAuthCommon.GetGUID32()));
            param.Add(new UrlParameter("oauth_signature_method", "HMAC-SHA1"));
            param.Add(new UrlParameter("oauth_timestamp", OAuthCommon.GetTimestamp()));
            param.Add(new UrlParameter("oauth_token", user.Token));
            param.Add(new UrlParameter("oauth_version", "1.0"));
            param.Sort(new UrlParameterCompre());

            StringBuilder sbSign2 = new StringBuilder().Append("GET&")
                                    .Append(Rfc3986.Encode(user_info))
                                    .Append("&")
                                    .Append(Rfc3986.Encode(OAuthCommon.GetUrlParameter(param)));

            param.Add(new UrlParameter("oauth_signature", Rfc3986.Encode(OAuthCommon.GetHMACSHA1(Rfc3986.Encode(config.AppSecret), Rfc3986.Encode(user.Secret), sbSign2.ToString()))));
            param.Sort(new UrlParameterCompre());
            data = HttpHelper.SendGet(new StringBuilder().Append(user_info).Append("?").Append(OAuthCommon.GetUrlParameter(param)).ToString());

            user.UserID  = data.GetMatchingValues("\"id\":\"(.+?)\"", "\"id\":\"", "\"").FirstOrDefault() ?? "";
            user.Email   = data.GetMatchingValues("\"email\":\"(.+?)\"", "\"email\":\"", "\"").FirstOrDefault() ?? "";
            user.Name    = data.GetMatchingValues("\"screen_name\":\"(.+?)\"", "\"screen_name\":\"", "\"").FirstOrDefault() ?? "";
            user.Sex     = (data.GetMatchingValues("\"gender\":\"(.+?)\"", "\"gender\":\"", "\"").FirstOrDefault() ?? "") == "1" ? 1 : 0;
            user.Header  = data.GetMatchingValues("\"profile_image_url\":\"(.+?)\"", "\"profile_image_url\":\"", "\"").FirstOrDefault() ?? "";
            user.Address = data.GetMatchingValues("\"location\":\"(.+?)\"", "\"location\":\"", "\"").FirstOrDefault() ?? "";

            //{"id":"268563401","screen_name":"livexy","name":"","location":"上海市,徐汇区","description":"","url":"","gender":"0",
            //"profile_image_url":"http://s4.cr.itc.cn/img/t/avt_48.jpg","protected":true,"followers_count":1,"profile_background_color":"",
            //"profile_text_color":"","profile_link_color":"","profile_sidebar_fill_color":"","profile_sidebar_border_color":"","friends_count":7,
            //"created_at":"Fri Dec 02 13:26:29 +0800 2011","favourites_count":0,"utc_offset":"","time_zone":"","profile_background_image_url":"",
            //"notifications":"","geo_enabled":false,"statuses_count":0,"following":true,"verified":false,"lang":"zh_cn","contributors_enabled":false}
            //Msg.Write(GetFriendsInfo(user.Token, user.Secret).ToJson());
            //SendText(user.Token, user.Secret, "测试数据2");
            return(user);
        }
예제 #14
0
        /// <summary>
        /// 取登录账号好友信息
        /// </summary>
        /// <param name="accessToken">Access Token</param>
        /// <param name="accessSecret">Access Secret</param>
        /// <returns>取登录账号好友信息</returns>
        public IList <UserInfo> GetFriendsInfo(string accessToken, string accessSecret)
        {
            IList <UserInfo> list = new List <UserInfo>();
            bool             isTrue = true; int count = 5; int page = 1;

            while (isTrue)
            {
                List <UrlParameter> param = new List <UrlParameter>();
                param.Add(new UrlParameter("oauth_consumer_key", config.AppKey));
                param.Add(new UrlParameter("oauth_nonce", OAuthCommon.GetGUID32()));
                param.Add(new UrlParameter("oauth_signature_method", "HMAC-SHA1"));
                param.Add(new UrlParameter("oauth_timestamp", OAuthCommon.GetTimestamp()));
                param.Add(new UrlParameter("oauth_token", accessToken));
                param.Add(new UrlParameter("oauth_version", "1.0"));
                param.Add(new UrlParameter("page", page));
                param.Add(new UrlParameter("count", count));
                param.Sort(new UrlParameterCompre());

                StringBuilder sbSign = new StringBuilder().Append("GET&")
                                       .Append(Rfc3986.Encode(friends_list))
                                       .Append("&")
                                       .Append(Rfc3986.Encode(OAuthCommon.GetUrlParameter(param)));

                param.Add(new UrlParameter("oauth_signature", Rfc3986.Encode(OAuthCommon.GetHMACSHA1(Rfc3986.Encode(config.AppSecret), Rfc3986.Encode(accessSecret), sbSign.ToString()))));
                param.Sort(new UrlParameterCompre());
                string data = "";
                try {
                    data = HttpHelper.SendGet(new StringBuilder().Append(friends_list).Append("?").Append(OAuthCommon.GetUrlParameter(param)).ToString());
                    data = data.Substring(1, data.Length - 2);
                } catch {}
                IList <string> userlist = data.GetMatchingValues("{\"id\":\"(.+?)}}", "{", "}}");

                foreach (string info in userlist)
                {
                    UserInfo user = new UserInfo();
                    user.UserID  = info.GetMatchingValues("\"id\":\"(.+?)\"", "\"id\":\"", "\"").FirstOrDefault() ?? "";
                    user.Email   = info.GetMatchingValues("\"email\":\"(.+?)\"", "\"email\":\"", "\"").FirstOrDefault() ?? "";
                    user.Name    = info.GetMatchingValues("\"screen_name\":\"(.+?)\"", "\"screen_name\":\"", "\"").FirstOrDefault() ?? "";
                    user.Sex     = (info.GetMatchingValues("\"gender\":\"(.+?)\"", "\"gender\":\"", "\"").FirstOrDefault() ?? "") == "1" ? 1 : 0;
                    user.Address = info.GetMatchingValues("\"location\":\"(.+?)\"", "\"location\":\"", "\"").FirstOrDefault() ?? "";
                    user.Header  = info.GetMatchingValues("\"profile_image_url\":\"(.+?)\"", "\"profile_image_url\":\"", "\"").FirstOrDefault() ?? "";
                    list.Add(user);
                }

                if (userlist.IsNull() || userlist.Count == 0)
                {
                    isTrue = false;
                }
                page++;
            }
            ;

            //"users":[
            //{"id":"8641996","screen_name":"新闻头条","name":"","location":"北京市,海淀区","description":"","url":"","gender":"1","profile_image_url":"http://s4.cr.itc.cn/mblog/icon/c7/4b/m_13119583882378.JPG","protected":true,"followers_count":5301900,"profile_background_color":"","profile_text_color":"","profile_link_color":"","profile_sidebar_fill_color":"","profile_sidebar_border_color":"","friends_count":1217,"created_at":"Tue Jun 29 14:35:44 +0800 2010","favourites_count":5,"utc_offset":"","time_zone":"","profile_background_image_url":"","notifications":"","geo_enabled":false,"statuses_count":18590,"following":true,"verified":true,"lang":"zh_cn","contributors_enabled":false,"status":{"created_at":"Fri Dec 09 13:05:40 +0800 2011","id":"2463351713","text":"【乌鲁木齐一女记者身中5刀顽强自救脱险 】12月6日晚11时30分,新疆都市报社会新闻女记者李娜下班回家,刚进入小区,突遭歹徒持刀抢劫,身中5刀,胸腔、腹腔、左臂、左腿等多处被捅,左肺部破裂。受伤后她淡定招呼出租车将其送往医院,并清醒报警。http://t.itc.cn/LHsfW","source":"搜狐微博","favorited":false,"truncated":"","in_reply_to_status_id":"","in_reply_to_user_id":"","in_reply_to_screen_name":"","small_pic":"http://s2.t.itc.cn/mblog/pic/201112_9_13/f_5772229398968603.jpg","middle_pic":"http://s2.t.itc.cn/mblog/pic/201112_9_13/m_5772229398968603.jpg","original_pic":"http://s2.t.itc.cn/mblog/pic/201112_9_13/5772229398968603.jpg"}},
            //{"id":"6376033","screen_name":"搜狐视频","name":"","location":"北京市,-","description":"搜狐视频tv.sohu.com 带给你每日最及时的新闻、电影、电视剧、纪录片、动画片等资讯,敬请关注!","url":"","gender":"1","profile_image_url":"http://s5.cr.itc.cn/mblog/icon/ac/39/m_13083074776832.jpg","protected":true,"followers_count":2540941,"profile_background_color":"","profile_text_color":"","profile_link_color":"","profile_sidebar_fill_color":"","profile_sidebar_border_color":"","friends_count":531,"created_at":"Tue Jun 08 15:16:04 +0800 2010","favourites_count":2,"utc_offset":"","time_zone":"","profile_background_image_url":"","notifications":"","geo_enabled":false,"statuses_count":6694,"following":true,"verified":true,"lang":"zh_cn","contributors_enabled":false,"status":{"created_at":"Fri Dec 09 12:03:09 +0800 2011","id":"2462806849","text":"#搜狐视频微视听#【何洁《爱过的你》MV首播】何洁全新专辑中,最后曝光同时也最受网友青睐的疗伤系主打情歌《爱过的你》MV正式首播。MV中何洁展现出的演技简直可以用出神入化来形容,每一种情绪,每一种状态都拿捏得特别到位,而且每场戏都是一遍通过…… http://t.itc.cn/Lu9HL","source":"搜狐微博","favorited":false,"truncated":"","in_reply_to_status_id":"","in_reply_to_user_id":"","in_reply_to_screen_name":"","small_pic":"http://s2.t.itc.cn/mblog/pic/201112_9_12/f_8629582797796467.jpg","middle_pic":"http://s2.t.itc.cn/mblog/pic/201112_9_12/m_8629582797796467.jpg","original_pic":"http://s2.t.itc.cn/mblog/pic/201112_9_12/8629582797796467.jpg"}},
            //{"id":"1323475","screen_name":"搜狐科学","name":"","location":"北京市,-","description":"浩瀚的宇宙+奇异的生物+绝美的景观+历史的痕迹=搜狐科学频道。","url":"","gender":"1","profile_image_url":"http://s5.cr.itc.cn/mblog/icon/f7/db/m_12706074122238.jpg","protected":false,"followers_count":2246515,"profile_background_color":"","profile_text_color":"","profile_link_color":"","profile_sidebar_fill_color":"","profile_sidebar_border_color":"","friends_count":17,"created_at":"Wed Apr 07 10:26:38 +0800 2010","favourites_count":0,"utc_offset":"","time_zone":"","profile_background_image_url":"","notifications":"","geo_enabled":false,"statuses_count":943,"following":true,"verified":true,"lang":"zh_cn","contributors_enabled":false,"status":{"created_at":"Fri Dec 09 12:30:02 +0800 2011","id":"2463028113","text":"【瑞士发现癌细胞扩散蛋白质 或开启治疗新途径】瑞士科学家近期发现了一种促进肿瘤扩散和转移的“主力”蛋白质——成骨细胞特异因子-2。实验证明,控制这种蛋白质的数量能够有效抑制恶性肿瘤的活跃程度。这一发现将有望给癌症治疗开辟一条全新的途径。http://t.itc.cn/L3RsH","source":"皮皮精灵","favorited":false,"truncated":"","in_reply_to_status_id":"","in_reply_to_user_id":"","in_reply_to_screen_name":"","small_pic":"http://s2.t.itc.cn/mblog/pic/201112_9_12/f_8631221896284467.jpg","middle_pic":"http://s2.t.itc.cn/mblog/pic/201112_9_12/m_8631221896284467.jpg","original_pic":"http://s2.t.itc.cn/mblog/pic/201112_9_12/8631221896284467.jpg"}},
            //{"id":"1333002","screen_name":"财经头条","name":"","location":"北京市,-","description":"及时资讯、独家爆料、麻辣点评,以财经视角关注民生视野,一起来微博吧!","url":"","gender":"1","profile_image_url":"http://s4.cr.itc.cn/mblog/icon/29/c7/m_12931723592217.jpg","protected":false,"followers_count":6491415,"profile_background_color":"","profile_text_color":"","profile_link_color":"","profile_sidebar_fill_color":"","profile_sidebar_border_color":"","friends_count":1458,"created_at":"Thu Apr 08 16:39:36 +0800 2010","favourites_count":4,"utc_offset":"","time_zone":"","profile_background_image_url":"","notifications":"","geo_enabled":false,"statuses_count":15916,"following":true,"verified":true,"lang":"zh_cn","contributors_enabled":false,"status":{"created_at":"Fri Dec 09 12:07:59 +0800 2011","id":"2462845477","text":"【东星航空诉民航中南局一审败诉】2009年3月,民航中南局据武汉市政府一纸公函责令东星航空停飞。距离一审整整7个月,东星诉民航中南局这一内地民航第一“民告官”案一审结果终于出来了:广州白云区法院判东星航空败诉。@东星集团 新闻发言人@兰剑敏 称,东星集团将上诉到底。","source":"搜狐微博","favorited":false,"truncated":"","in_reply_to_status_id":"","in_reply_to_user_id":"","in_reply_to_screen_name":"","small_pic":"http://s3.t.itc.cn/mblog/pic/201112_9_12/f_8629896712993467.jpg","middle_pic":"http://s3.t.itc.cn/mblog/pic/201112_9_12/m_8629896712993467.jpg","original_pic":"http://s3.t.itc.cn/mblog/pic/201112_9_12/8629896712993467.jpg"}},
            //{"id":"205207873","screen_name":"搜狐微博官方辟谣","name":"","location":"北京市,海淀区","description":"搜狐微博辟谣官方账号","url":"","gender":"1","profile_image_url":"http://s5.cr.itc.cn/mblog/icon/61/30/m_13153908401706.jpg","protected":true,"followers_count":2725279,"profile_background_color":"","profile_text_color":"","profile_link_color":"","profile_sidebar_fill_color":"","profile_sidebar_border_color":"","friends_count":0,"created_at":"Thu Sep 01 20:17:53 +0800 2011","favourites_count":0,"utc_offset":"","time_zone":"","profile_background_image_url":"","notifications":"","geo_enabled":false,"statuses_count":71,"following":true,"verified":true,"lang":"zh_cn","contributors_enabled":false,"status":{"created_at":"Fri Dec 09 10:41:30 +0800 2011","id":"2462125691","text":"近日,网传“最新最恐怖的拐卖妇女方式出炉”一文,经搜狐微博查证,纯属谣言。近日,多位博友发表微博称“最新最恐怖的拐卖妇女方式出炉”并配图一张,详细的表述了所谓的拐卖过程。经搜狐微博查证,早在今年4月,京、上、广三地皆有类似谣言传播,北京、广州警方均在微博上发表过辟谣声明,表示当地警方并未接到相关警情,且谣言中的地铁线路、站名等均有错误,(新闻链接 http://t.itc.cn/LvAXy)国内各...","source":"搜狐微博","favorited":false,"truncated":"","in_reply_to_status_id":"","in_reply_to_user_id":"","in_reply_to_screen_name":"","small_pic":"http://s2.t.itc.cn/mblog/pic/201112_9_10/f_5763578358261603.jpg","middle_pic":"http://s2.t.itc.cn/mblog/pic/201112_9_10/m_5763578358261603.jpg","original_pic":"http://s2.t.itc.cn/mblog/pic/201112_9_10/5763578358261603.jpg"}},
            //{"id":"16053","screen_name":"娱乐头条","name":"","location":"北京市,-","description":"搜狐娱乐频道微博,提供最新明星八卦、影视资讯、音乐试听等内容,每周7天每天24小时更新,敬请关注!","url":"","gender":"1","profile_image_url":"http://s5.cr.itc.cn/mblog/icon/09/50/m_12991200389544.jpg","protected":true,"followers_count":5411328,"profile_background_color":"","profile_text_color":"","profile_link_color":"","profile_sidebar_fill_color":"","profile_sidebar_border_color":"","friends_count":781,"created_at":"Thu Jan 07 17:34:26 +0800 2010","favourites_count":8,"utc_offset":"","time_zone":"","profile_background_image_url":"","notifications":"","geo_enabled":false,"statuses_count":17283,"following":true,"verified":true,"lang":"zh_cn","contributors_enabled":false,"status":{"created_at":"Fri Dec 09 11:20:41 +0800 2011","id":"2462471205","text":"【#Touch of Evil#】去年纽约时报做的年度策划是13位演员的表演课,今年的盘点新鲜出炉,主题是邪恶接触(touch of evil)且看布拉德-皮特(Brad Pitt)戏仿《#橡皮头#》中的杰克-南斯。好莱坞大牌如何演绎经典?且看皮特如何像经典致敬!http://t.itc.cn/LmnNU http://t.itc.cn/L3Pvp","source":"搜狐微博","favorited":false,"truncated":"","in_reply_to_status_id":"","in_reply_to_user_id":"","in_reply_to_screen_name":"","small_pic":"http://s2.t.itc.cn/mblog/pic/201112_9_11/f_5765897143974603.jpg","middle_pic":"http://s2.t.itc.cn/mblog/pic/201112_9_11/m_5765897143974603.jpg","original_pic":"http://s2.t.itc.cn/mblog/pic/201112_9_11/5765897143974603.jpg"}},
            //{"id":"31963453","screen_name":"搜狐微博官方","name":"","location":"北京市,海淀区","description":"搜狐微博官方活动账号","url":"","gender":"0","profile_image_url":"http://s5.cr.itc.cn/mblog/icon/6a/98/m_13014576518865.jpg","protected":true,"followers_count":13601146,"profile_background_color":"","profile_text_color":"","profile_link_color":"","profile_sidebar_fill_color":"","profile_sidebar_border_color":"","friends_count":158,"created_at":"Fri Jan 07 16:21:46 +0800 2011","favourites_count":0,"utc_offset":"","time_zone":"","profile_background_image_url":"","notifications":"","geo_enabled":false,"statuses_count":2789,"following":true,"verified":true,"lang":"zh_cn","contributors_enabled":false,"status":{"created_at":"Fri Dec 09 09:55:01 +0800 2011","id":"2461704594","text":"看剧抽奖:每周五下午3:30来搜狐视频看 《生活大爆炸》http://t.itc.cn/L3ruv 以 #生活大爆炸#为关键词写下本集你认为最有趣的3个段子发一条微博,我们将抽选10名参与者获得有搜狐微博徽标的iPhone充电宝!由@搜狐视频 公布获奖名单。活动详情:http://t.itc.cn/L464r","source":"搜狐微博","favorited":false,"truncated":"","in_reply_to_status_id":"","in_reply_to_user_id":"","in_reply_to_screen_name":"","small_pic":"http://s3.t.itc.cn/mblog/pic/201112_9_9/f_8621637448428467.jpg","middle_pic":"http://s3.t.itc.cn/mblog/pic/201112_9_9/m_8621637448428467.jpg","original_pic":"http://s3.t.itc.cn/mblog/pic/201112_9_9/8621637448428467.jpg"}}
            //],"cursor_id":17283996
            return(list);
        }
예제 #15
0
        /// <summary>
        /// 取登录账号信息
        /// </summary>
        /// <returns>取登录账号信息</returns>
        public UserInfo GetUserInfo()
        {
            UserInfo user = new UserInfo();

            List <UrlParameter> param = new List <UrlParameter>();

            param.Add(new UrlParameter("oauth_consumer_key", config.AppKey));
            param.Add(new UrlParameter("oauth_nonce", OAuthCommon.GetGUID32()));
            param.Add(new UrlParameter("oauth_signature_method", "HMAC-SHA1"));
            param.Add(new UrlParameter("oauth_timestamp", OAuthCommon.GetTimestamp()));
            param.Add(new UrlParameter("oauth_token", Request2.GetQ("oauth_token")));
            param.Add(new UrlParameter("oauth_verifier", Request2.GetQ("oauth_verifier")));
            param.Add(new UrlParameter("oauth_version", "1.0"));
            param.Sort(new UrlParameterCompre());

            StringBuilder sbSign = new StringBuilder().Append("GET&")
                                   .Append(access_token.UrlEncode2())
                                   .Append("&")
                                   .Append(OAuthCommon.GetUrlParameter(param).UrlEncode2());

            param.Add(new UrlParameter("oauth_signature", OAuthCommon.GetHMACSHA1(config.AppSecret, Session2.Get("oauth_token_secret"), sbSign.ToString()).UrlEncode2()));
            param.Sort(new UrlParameterCompre());
            string data = HttpHelper.SendGet(new StringBuilder().Append(access_token).Append("?").Append(OAuthCommon.GetUrlParameter(param)).ToString()) + "&";

            user.Token  = data.GetMatchingValues("oauth_token=(.+?)&", "oauth_token=", "&").FirstOrDefault() ?? "";
            user.Secret = data.GetMatchingValues("oauth_token_secret=(.+?)&", "oauth_token_secret=", "&").FirstOrDefault() ?? "";

            param.Clear();
            param.Add(new UrlParameter("oauth_consumer_key", config.AppKey));
            param.Add(new UrlParameter("oauth_nonce", OAuthCommon.GetGUID32()));
            param.Add(new UrlParameter("oauth_signature_method", "HMAC-SHA1"));
            param.Add(new UrlParameter("oauth_timestamp", OAuthCommon.GetTimestamp()));
            param.Add(new UrlParameter("oauth_token", user.Token));
            param.Add(new UrlParameter("oauth_version", "1.0"));
            param.Sort(new UrlParameterCompre());

            StringBuilder sbSign2 = new StringBuilder().Append("GET&")
                                    .Append(user_info.UrlEncode2())
                                    .Append("&")
                                    .Append(OAuthCommon.GetUrlParameter(param).UrlEncode2());

            param.Add(new UrlParameter("oauth_signature", OAuthCommon.GetHMACSHA1(config.AppSecret, user.Secret, sbSign2.ToString()).UrlEncode2()));
            param.Sort(new UrlParameterCompre());

            data = HttpHelper.SendGet(new StringBuilder().Append(user_info).Append("?").Append(OAuthCommon.GetUrlParameter(param)).ToString());

            user.UserID  = data.GetMatchingValues("\"id\":\"(.+?)\"", "\"id\":\"", "\"").FirstOrDefault() ?? "";
            user.Email   = data.GetMatchingValues("\"email\":\"(.+?)\"", "\"email\":\"", "\"").FirstOrDefault() ?? "";
            user.Name    = data.GetMatchingValues("\"name\":\"(.+?)\"", "\"name\":\"", "\"").FirstOrDefault() ?? "";
            user.Sex     = (data.GetMatchingValues("\"gender\":\"(.+?)\"", "\"gender\":\"", "\"").FirstOrDefault() ?? "") == "1" ? 1 : 0;
            user.Header  = data.GetMatchingValues("\"profile_image_url\":\"(.+?)\"", "\"profile_image_url\":\"", "\"").FirstOrDefault() ?? "";
            user.Address = data.GetMatchingValues("\"location\":\"(.+?)\"", "\"location\":\"", "\"").FirstOrDefault() ?? "";

            //{"status":null,"following":false,"blocking":false,"followed_by":false,"name":"cexo255","location":"上海市,徐汇区",
            //"id":"959281886828269520","description":"","email":"*****@*****.**","gender":"0","verified":false,"url":"","screen_name":"cexo255",
            //"profile_image_url":"http://oimagea3.ydstatic.com/image?w=48&h=48&url=http%3A%2F%2Fimg1.cache.netease.com%2Ft%2Fimg%2Fdefault80.png",
            //"created_at":"Wed Apr 21 13:19:53 +0800 2010","darenRec":null,"favourites_count":"0","followers_count":"0","friends_count":"0",
            //"geo_enable":false,"icorp":"0","realName":null,"statuses_count":"0","sysTag":null,"userTag":null,"in_groups":[]}
            //Msg.Write(GetFriendsInfo(user.Token, user.Secret).ToJson());
            //SendText(user.Token, user.Secret, "测试数据2");
            return(user);
        }